AVR Libc Home Page AVRs AVR Libc Development Pages
Main Page User Manual Library Reference FAQ Alphabetical Index Example Projects

power.h

Go to the documentation of this file.
00001 /* Copyright (c) 2006, 2007, 2008  Eric B. Weddington
00002    All rights reserved.
00003 
00004    Redistribution and use in source and binary forms, with or without
00005    modification, are permitted provided that the following conditions are met:
00006 
00007    * Redistributions of source code must retain the above copyright
00008      notice, this list of conditions and the following disclaimer.
00009    * Redistributions in binary form must reproduce the above copyright
00010      notice, this list of conditions and the following disclaimer in
00011      the documentation and/or other materials provided with the
00012      distribution.
00013    * Neither the name of the copyright holders nor the names of
00014      contributors may be used to endorse or promote products derived
00015      from this software without specific prior written permission.
00016 
00017   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00018   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00019   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00020   ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
00021   LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00022   CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00023   SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00024   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00025   CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00026   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00027   POSSIBILITY OF SUCH DAMAGE. */
00028 
00029 /* $Id: power.h 2213 2011-02-16 08:44:23Z aboyapati $ */
00030 
00031 #ifndef _AVR_POWER_H_
00032 #define _AVR_POWER_H_   1
00033 
00034 #include <avr/io.h>
00035 #include <stdint.h>
00036 
00037 
00038 /** \file */
00039 /** \defgroup avr_power <avr/power.h>: Power Reduction Management
00040 
00041 \code #include <avr/power.h>\endcode
00042 
00043 Many AVRs contain a Power Reduction Register (PRR) or Registers (PRRx) that 
00044 allow you to reduce power consumption by disabling or enabling various on-board 
00045 peripherals as needed.
00046 
00047 There are many macros in this header file that provide an easy interface
00048 to enable or disable on-board peripherals to reduce power. See the table below.
00049 
00050 \note Not all AVR devices have a Power Reduction Register (for example
00051 the ATmega128). On those devices without a Power Reduction Register, these 
00052 macros are not available.
00053 
00054 \note Not all AVR devices contain the same peripherals (for example, the LCD
00055 interface), or they will be named differently (for example, USART and 
00056 USART0). Please consult your device's datasheet, or the header file, to 
00057 find out which macros are applicable to your device.
00058 
00059 */
00060 
00061 
00062 /** \addtogroup avr_power
00063 
00064 \anchor avr_powermacros
00065 <small>
00066 <center>
00067 <table border="3">
00068   <tr>
00069     <td width="10%"><strong>Power Macro</strong></td>
00070     <td width="15%"><strong>Description</strong></td>
00071     <td width="75%"><strong>Applicable for device</strong></td>
00072   </tr>
00073 
00074   <tr>
00075     <td>power_adc_enable()</td>
00076     <td>Enable the Analog to Digital Converter module.</td>
00077     <td>ATmega640, ATmega1280, ATmega1281, ATmega128RFA1, ATmega2560, ATmega2561, AT90USB646, AT90USB647, AT90USB1286, AT90USB1287, AT90PWM1, AT90PWM2, AT90PWM2B, AT90PWM3, AT90PWM3B, AT90PWM216, AT90PWM316, AT90PWM81, ATmega165, ATmega165P, ATmega325, ATmega325A, ATmega325PA, ATmega3250, ATmega3250A, ATmega3250PA, ATmega645, ATmega6450, ATmega169, ATmega169P, ATmega329, ATmega329A, ATmega3290, ATmega3290A, ATmega3290PA, ATmega649, ATmega6490, ATmega164P, ATmega324P, ATmega644, ATmega48, ATmega88, ATmega168, ATtiny24, ATtiny44, ATtiny84, ATtiny84A, ATtiny25, ATtiny45, ATtiny85, ATtiny261, ATtiny461, ATtiny861, ATxmega128B1</td>
00078   </tr>
00079 
00080   <tr>
00081     <td>power_adc_disable()</td>
00082     <td>Disable the Analog to Digital Converter module.</td>
00083     <td>ATmega640, ATmega1280, ATmega1281, ATmega128RFA1, ATmega2560, ATmega2561, AT90USB646, AT90USB647, AT90USB1286, AT90USB1287, AT90PWM1, AT90PWM2, AT90PWM2B, AT90PWM3, AT90PWM3B, AT90PWM216, AT90PWM316, AT90PWM81, ATmega165, ATmega165P, ATmega325, ATmega325A, ATmega325PA, ATmega3250, ATmega3250A, ATmega3250PA, ATmega645, ATmega6450, ATmega169, ATmega169P, ATmega329, ATmega329A, ATmega3290, ATmega3290A, ATmega3290PA, ATmega649, ATmega6490, ATmega164P, ATmega324P, ATmega644, ATmega48, ATmega88, ATmega168, ATtiny24, ATtiny44, ATtiny84, ATtiny84A, ATtiny25, ATtiny45, ATtiny85, ATtiny261, ATtiny461, ATtiny861, ATxmega128B1</td>
00084   </tr>
00085 
00086   <tr>
00087     <td>power_lcd_enable()</td>
00088     <td>Enable the LCD module.</td>
00089     <td>ATmega169, ATmega169P, ATmega329, ATmega329A, ATmega3290, ATmega3290A, ATmega3290PA, ATmega649, ATmega6490, ATxmega128B1</td>
00090   </tr>
00091 
00092   <tr>
00093     <td>power_lcd_disable().</td>
00094     <td>Disable the LCD module.</td>
00095     <td>ATmega169, ATmega169P, ATmega329, ATmega329A, ATmega3290, ATmega3290A, ATmega3290PA, ATmega649, ATmega6490, ATxmega128B1</td>
00096   </tr>
00097 
00098   <tr>
00099     <td>power_pscr_enable()</td>
00100     <td>Enable the Reduced Power Stage Controller module.</td>
00101     <td>AT90PWM81</td>
00102   </tr>
00103 
00104   <tr>
00105     <td>power_pscr_disable()</td>
00106     <td>Disable the Reduced Power Stage Controller module.</td>
00107     <td>AT90PWM81</td>
00108   </tr>
00109 
00110   <tr>
00111     <td>power_psc0_enable()</td>
00112     <td>Enable the Power Stage Controller 0 module.</td>
00113     <td>AT90PWM1, AT90PWM2, AT90PWM2B, AT90PWM3, AT90PWM3B</td>
00114   </tr>
00115 
00116   <tr>
00117     <td>power_psc0_disable()</td>
00118     <td>Disable the Power Stage Controller 0 module.</td>
00119     <td>AT90PWM1, AT90PWM2, AT90PWM2B, AT90PWM3, AT90PWM3B</td>
00120   </tr>
00121 
00122   <tr>
00123     <td>power_psc1_enable()</td>
00124     <td>Enable the Power Stage Controller 1 module.</td>
00125     <td>AT90PWM1, AT90PWM2, AT90PWM2B, AT90PWM3, AT90PWM3B</td>
00126   </tr>
00127 
00128   <tr>
00129     <td>power_psc1_disable()</td>
00130     <td>Disable the Power Stage Controller 1 module.</td>
00131     <td>AT90PWM1, AT90PWM2, AT90PWM2B, AT90PWM3, AT90PWM3B</td>
00132   </tr>
00133 
00134   <tr>
00135     <td>power_psc2_enable()</td>
00136     <td>Enable the Power Stage Controller 2 module.</td>
00137     <td>AT90PWM1, AT90PWM2, AT90PWM2B, AT90PWM3, AT90PWM3B, AT90PWM81</td>
00138   </tr>
00139 
00140   <tr>
00141     <td>power_psc2_disable()</td>
00142     <td>Disable the Power Stage Controller 2 module.</td>
00143     <td>AT90PWM1, AT90PWM2, AT90PWM2B, AT90PWM3, AT90PWM3B, AT90PWM81</td>
00144   </tr>
00145 
00146   <tr>
00147     <td>power_spi_enable()</td>
00148     <td>Enable the Serial Peripheral Interface module.</td>
00149     <td>ATmega640, ATmega1280, ATmega1281, ATmega128RFA1, ATmega2560, ATmega2561, AT90USB646, AT90USB647, AT90USB1286, AT90USB1287, AT90PWM1, AT90PWM2, AT90PWM2B, AT90PWM3, AT90PWM3B, AT90PWM216, AT90PWM316, AT90PWM81, ATmega165, ATmega165P, ATmega325, ATmega325A, ATmega325PA, ATmega3250, ATmega3250A, ATmega3250PA, ATmega645, ATmega6450, ATmega169, ATmega169P, ATmega329, ATmega329A, ATmega3290, ATmega3290A, ATmega3290PA, ATmega649, ATmega6490, ATmega164P, ATmega324P, ATmega644, ATmega48, ATmega88, ATmega168, ATxmega128B1</td>
00150   </tr>
00151 
00152   <tr>
00153     <td>power_spi_disable()</td>
00154     <td>Disable the Serial Peripheral Interface module.</td>
00155     <td>ATmega640, ATmega1280, ATmega1281, ATmega128RFA1, ATmega2560, ATmega2561, AT90USB646, AT90USB647, AT90USB1286, AT90USB1287, AT90PWM1, AT90PWM2, AT90PWM2B, AT90PWM3, AT90PWM3B, AT90PWM216, AT90PWM316, AT90PWM81, ATmega165, ATmega165P, ATmega325, ATmega325A, ATmega325PA, ATmega3250, ATmega3250A, ATmega3250PA, ATmega645, ATmega6450, ATmega169, ATmega169P, ATmega329, ATmega329A, ATmega3290, ATmega3290A, ATmega3290PA, ATmega649, ATmega6490, ATmega164P, ATmega324P, ATmega644, ATmega48, ATmega88, ATmega168, ATxmega128B1</td>
00156   </tr>
00157 
00158   <tr>
00159     <td>power_timer0_enable()</td>
00160     <td>Enable the Timer 0 module.</td>
00161     <td>ATmega640, ATmega1280, ATmega1281, ATmega128RFA1, ATmega2560, ATmega2561, AT90USB646, AT90USB647, AT90USB1286, AT90USB1287, AT90PWM1, AT90PWM216, AT90PWM316, AT90PWM2, AT90PWM2B, AT90PWM3, AT90PWM3B, ATmega165, ATmega165P, ATmega325, ATmega325A, ATmega3250, ATmega3250A, ATmega645, ATmega6450, ATmega164P, ATmega324P, ATmega644, ATmega406, ATmega48, ATmega88, ATmega168, ATtiny24, ATtiny44, ATtiny84, ATtiny84A, ATtiny25, ATtiny45, ATtiny85, ATtiny261, ATtiny461, ATtiny861, ATxmega128B1</td>
00162   </tr>
00163 
00164   <tr>
00165     <td>power_timer0_disable()</td>
00166     <td>Disable the Timer 0 module.</td>
00167     <td>ATmega640, ATmega1280, ATmega1281, ATmega128RFA1, ATmega2560, ATmega2561, AT90USB646, AT90USB647, AT90USB1286, AT90USB1287, AT90PWM1, AT90PWM2, AT90PWM2B, AT90PWM3, AT90PWM3B, AT90PWM216, AT90PWM316, ATmega165, ATmega165P, ATmega325, ATmega325A, ATmega3250, ATmega3250A, ATmega645, ATmega6450, ATmega164P, ATmega324P, ATmega644, ATmega406, ATmega48, ATmega88, ATmega168, ATtiny24, ATtiny44, ATtiny84, ATtiny84A, ATtiny25, ATtiny45, ATtiny85, ATtiny261, ATtiny461, ATtiny861, ATxmega128B1</td>
00168   </tr>
00169 
00170   <tr>
00171     <td>power_timer1_enable()</td>
00172     <td>Enable the Timer 1 module.</td>
00173     <td>ATmega640, ATmega1280, ATmega1281, ATmega128RFA1, ATmega2560, ATmega2561, AT90USB646, AT90USB647, AT90USB1286, AT90USB1287, AT90PWM1, AT90PWM2, AT90PWM2B, AT90PWM3, AT90PWM3B, AT90PWM216, AT90PWM316, AT90PWM81, ATmega165, ATmega165P, ATmega325, ATmega325A, ATmega325PA, ATmega3250, ATmega3250A, ATmega3250PA, ATmega645, ATmega6450, ATmega169, ATmega169P, ATmega329, ATmega329A, ATmega3290, ATmega3290A, ATmega3290PA, ATmega649, ATmega6490, ATmega164P, ATmega324P, ATmega644, ATmega406, ATmega48, ATmega88, ATmega168, ATtiny24, ATtiny44, ATtiny84, ATtiny84A, ATtiny25, ATtiny45, ATtiny85, ATtiny261, ATtiny461, ATtiny861, ATxmega128B1</td>
00174   </tr>
00175 
00176   <tr>
00177     <td>power_timer1_disable()</td>
00178     <td>Disable the Timer 1 module.</td>
00179     <td>ATmega640, ATmega1280, ATmega1281, ATmega128RFA1, ATmega2560, ATmega2561, AT90USB646, AT90USB647, AT90USB1286, AT90USB1287, AT90PWM1, AT90PWM2, AT90PWM2B, AT90PWM3, AT90PWM3B, AT90PWM216, AT90PWM316, AT90PWM81, ATmega165, ATmega165P, ATmega325, ATmega325A, ATmega325PA, ATmega3250, ATmega3250A, ATmega3250PA, ATmega645, ATmega6450, ATmega169, ATmega169P, ATmega329, ATmega329A, ATmega3290, ATmega3290A, ATmega3290PA, ATmega649, ATmega6490, ATmega164P, ATmega324P, ATmega644, ATmega406, ATmega48, ATmega88, ATmega168, ATtiny24, ATtiny44, ATtiny84, ATtiny84A, ATtiny25, ATtiny45, ATtiny85, ATtiny261, ATtiny461, ATtiny861, ATxmega128B1</td>
00180   </tr>
00181 
00182   <tr>
00183     <td>power_timer2_enable()</td>
00184     <td>Enable the Timer 2 module.</td>
00185     <td>ATmega640, ATmega1280, ATmega1281, ATmega128RFA1, ATmega2560, ATmega2561, AT90USB646, AT90USB647, AT90USB1286, AT90USB1287, ATmega164P, ATmega324P, ATmega644, ATmega48, ATmega88, ATmega168</td>
00186   </tr>
00187 
00188   <tr>
00189     <td>power_timer2_disable()</td>
00190     <td>Disable the Timer 2 module.</td>
00191     <td>ATmega640, ATmega1280, ATmega1281, ATmega128RFA1, ATmega2560, ATmega2561, AT90USB646, AT90USB647, AT90USB1286, AT90USB1287, ATmega164P, ATmega324P, ATmega644, ATmega48, ATmega88, ATmega168</td>
00192   </tr>
00193 
00194   <tr>
00195     <td>power_timer3_enable()</td>
00196     <td>Enable the Timer 3 module.</td>
00197     <td>ATmega640, ATmega1280, ATmega1281, ATmega128RFA1, ATmega2560, ATmega2561, AT90USB646, AT90USB647, AT90USB1286, AT90USB1287</td>
00198   </tr>
00199 
00200   <tr>
00201     <td>power_timer3_disable()</td>
00202     <td>Disable the Timer 3 module.</td>
00203     <td>ATmega640, ATmega1280, ATmega1281, ATmega128RFA1, ATmega2560, ATmega2561, AT90USB646, AT90USB647, AT90USB1286, AT90USB1287</td>
00204   </tr>
00205 
00206   <tr>
00207     <td>power_timer4_enable()</td>
00208     <td>Enable the Timer 4 module.</td>
00209     <td>ATmega640, ATmega1280, ATmega1281, ATmega128RFA1, ATmega2560, ATmega2561</td>
00210   </tr>
00211 
00212   <tr>
00213     <td>power_timer4_disable()</td>
00214     <td>Disable the Timer 4 module.</td>
00215     <td>ATmega640, ATmega1280, ATmega1281, ATmega128RFA1, ATmega2560, ATmega2561</td>
00216   </tr>
00217 
00218   <tr>
00219     <td>power_timer5_enable()</td>
00220     <td>Enable the Timer 5 module.</td>
00221     <td>ATmega640, ATmega1280, ATmega1281, ATmega128RFA1, ATmega2560, ATmega2561</td>
00222   </tr>
00223 
00224   <tr>
00225     <td>power_timer5_disable()</td>
00226     <td>Disable the Timer 5 module.</td>
00227     <td>ATmega640, ATmega1280, ATmega1281, ATmega128RFA1, ATmega2560, ATmega2561</td>
00228   </tr>
00229 
00230   <tr>
00231     <td>power_twi_enable()</td>
00232     <td>Enable the Two Wire Interface module.</td>
00233     <td>ATmega640, ATmega1280, ATmega1281, ATmega128RFA1, ATmega2560, ATmega2561, AT90USB646, AT90USB647, AT90USB1286, AT90USB1287, ATmega164P, ATmega324P, ATmega644, ATmega406, ATmega48, ATmega88, ATmega168, ATxmega128B1</td>
00234   </tr>
00235 
00236   <tr>
00237     <td>power_twi_disable()</td>
00238     <td>Disable the Two Wire Interface module.</td>
00239     <td>ATmega640, ATmega1280, ATmega1281, ATmega128RFA1, ATmega2560, ATmega2561, AT90USB646, AT90USB647, AT90USB1286, AT90USB1287, ATmega164P, ATmega324P, ATmega644, ATmega406, ATmega48, ATmega88, ATmega168, ATxmega128B1</td>
00240   </tr>
00241 
00242   <tr>
00243     <td>power_usart_enable()</td>
00244     <td>Enable the USART module.</td>
00245     <td>AT90PWM2, AT90PWM2B, AT90PWM3, AT90PWM3B</td>
00246   </tr>
00247 
00248   <tr>
00249     <td>power_usart_disable()</td>
00250     <td>Disable the USART module.</td>
00251     <td>AT90PWM2, AT90PWM2B, AT90PWM3, AT90PWM3B</td>
00252   </tr>
00253 
00254   <tr>
00255     <td>power_usart0_enable()</td>
00256     <td>Enable the USART 0 module.</td>
00257     <td>ATmega640, ATmega1280, ATmega1281, ATmega128RFA1, ATmega2560, ATmega2561, ATmega165, ATmega165P, ATmega325, ATmega325A, ATmega325PA, ATmega3250, ATmega3250A, ATmega3250PA, ATmega645, ATmega6450, ATmega169, ATmega169P, ATmega329, ATmega329A, ATmega3290, ATmega3290A, ATmega3290PA, ATmega649, ATmega6490, ATmega164P, ATmega324P, ATmega644, ATmega48, ATmega88, ATmega168, ATxmega128B1</td>
00258   </tr>
00259 
00260   <tr>
00261     <td>power_usart0_disable()</td>
00262     <td>Disable the USART 0 module.</td>
00263     <td>ATmega640, ATmega1280, ATmega1281, ATmega128RFA1, ATmega2560, ATmega2561, ATmega165, ATmega165P, ATmega325, ATmega325A, ATmega325PA, ATmega3250, ATmega3250A, ATmega3250PA, ATmega645, ATmega6450, ATmega169, ATmega169P, ATmega329, ATmega329A, ATmega3290, ATmega3290A, ATmega3290PA, ATmega649, ATmega6490, ATmega164P, ATmega324P, ATmega644, ATmega48, ATmega88, ATmega168, ATxmega128B1</td>
00264   </tr>
00265 
00266   <tr>
00267     <td>power_usart1_enable()</td>
00268     <td>Enable the USART 1 module.</td>
00269     <td>ATmega640, ATmega1280, ATmega1281, ATmega128RFA1, ATmega2560, ATmega2561, AT90USB646, AT90USB647, AT90USB1286, AT90USB1287, ATmega164P, ATmega324P, ATmega644, ATxmega128B1</td>
00270   </tr>
00271 
00272   <tr>
00273     <td>power_usart1_disable()</td>
00274     <td>Disable the USART 1 module.</td>
00275     <td>ATmega640, ATmega1280, ATmega1281, ATmega128RFA1, ATmega2560, ATmega2561, AT90USB646, AT90USB647, AT90USB1286, AT90USB1287, ATmega164P, ATmega324P, ATmega644, ATxmega128B1</td>
00276   </tr>
00277 
00278   <tr>
00279     <td>power_usart2_enable()</td>
00280     <td>Enable the USART 2 module.</td>
00281     <td>ATmega640, ATmega1280, ATmega1281, ATmega2560, ATmega2561</td>
00282   </tr>
00283 
00284   <tr>
00285     <td>power_usart2_disable()</td>
00286     <td>Disable the USART 2 module.</td>
00287     <td>ATmega640, ATmega1280, ATmega1281, ATmega2560, ATmega2561</td>
00288   </tr>
00289 
00290   <tr>
00291     <td>power_usart3_enable()</td>
00292     <td>Enable the USART 3 module.</td>
00293     <td>ATmega640, ATmega1280, ATmega1281, ATmega2560, ATmega2561</td>
00294   </tr>
00295 
00296   <tr>
00297     <td>power_usart3_disable()</td>
00298     <td>Disable the USART 3 module.</td>
00299     <td>ATmega640, ATmega1280, ATmega1281, ATmega2560, ATmega2561</td>
00300   </tr>
00301 
00302   <tr>
00303     <td>power_usb_enable()</td>
00304     <td>Enable the USB module.</td>
00305     <td>AT90USB646, AT90USB647, AT90USB1286, AT90USB1287, ATxmega128B1</td>
00306   </tr>
00307 
00308   <tr>
00309     <td>power_usb_disable()</td>
00310     <td>Disable the USB module.</td>
00311     <td>AT90USB646, AT90USB647, AT90USB1286, AT90USB1287, ATxmega128B1</td>
00312   </tr>
00313 
00314   <tr>
00315     <td>power_usi_enable()</td>
00316     <td>Enable the Universal Serial Interface module.</td>
00317     <td>ATtiny24, ATtiny44, ATtiny84, ATtiny84A, ATtiny25, ATtiny45, ATtiny85, ATtiny261, ATtiny461, ATtiny861</td>
00318   </tr>
00319 
00320   <tr>
00321     <td>power_usi_disable()</td>
00322     <td>Disable the Universal Serial Interface module.</td>
00323     <td>ATtiny24, ATtiny44, ATtiny84, ATtiny84A, ATtiny25, ATtiny45, ATtiny85, ATtiny261, ATtiny461, ATtiny861</td>
00324   </tr>
00325 
00326   <tr>
00327     <td>power_vadc_enable()</td>
00328     <td>Enable the Voltage ADC module.</td>
00329     <td>ATmega406</td>
00330   </tr>
00331 
00332   <tr>
00333     <td>power_vadc_disable()</td>
00334     <td>Disable the Voltage ADC module.</td>
00335     <td>ATmega406</td>
00336   </tr>
00337 
00338   <tr>
00339     <td>power_all_enable()</td>
00340     <td>Enable all modules.</td>
00341     <td>ATxmega6A4, ATxmega32A4, ATxmega64A1, ATxmega64A1U, ATxmega64A3, ATxmegaA1, ATxmegaA1U, ATxmega128A3, ATxmega192A3, ATxmega256A3, ATxmegaA3B, ATxmega16D4, ATxmega32D4, ATxmega64D3, ATxmega128D3, ATxmega192D3, ATmega640, ATmega1280, ATmega1281, ATmega128RFA1, ATmega2560, ATmega2561, AT90USB646, AT90USB647, AT90USB1286, AT90USB1287, AT90PWM1, AT90PWM2, AT90PWM2B, AT90PWM3, AT90PWM3B, AT90PWM216, AT90PWM316, ATmega165, ATmega165P, ATmega325, ATmega325A, ATmega325PA, ATmega3250, ATmega3250A, ATmega3250PA, ATmega645, ATmega6450, ATmega169, ATmega169P, ATmega329, ATmega329A, ATmega3290, ATmega3290A, ATmega3290PA, ATmega649, ATmega6490, ATmega164P, ATmega324P, ATmega644, ATmega406, ATmega48, ATmega88, ATmega168, ATtiny24, ATtiny44, ATtiny84, ATtiny84A, ATtiny25, ATtiny45, ATtiny85, ATtiny261, ATtiny461, ATtiny861, ATxmega128B1</td>
00342   </tr>
00343 
00344   <tr>
00345     <td>power_all_disable()</td>
00346     <td>Disable all modules.</td>
00347     <td>ATxmega6A4, ATxmega32A4, ATxmega64A1, ATxmega64A1U, ATxmega64A3, ATxmegaA1, ATxmegaA1U, ATxmega128A3, ATxmega192A3, ATxmega256A3, ATxmegaA3B, ATxmega16D4, ATxmega32D4, ATxmega64D3, ATxmega128D3,ATxmega192D3, ATmega640, ATmega1280, ATmega1281, ATmega128RFA1, ATmega2560, ATmega2561, AT90USB646, AT90USB647, AT90USB1286, AT90USB1287, AT90PWM1, AT90PWM2, AT90PWM2B, AT90PWM3, AT90PWM3B, AT90PWM216, AT90PWM316, ATmega165, ATmega165P, ATmega325, ATmega325A, ATmega325PA, ATmega3250, ATmega3250A, ATmega3250PA, ATmega645, ATmega6450, ATmega169, ATmega169P, ATmega329, ATmega329A, ATmega3290, ATmega3290A, ATmega3290PA, ATmega649, ATmega6490, ATmega164P, ATmega324P, ATmega644, ATmega406, ATmega48, ATmega88, ATmega168, ATtiny24, ATtiny44, ATtiny84, ATtiny84A, ATtiny25, ATtiny45, ATtiny85, ATtiny261, ATtiny461, ATtiny861, ATxmega128B1</td>
00348   </tr>
00349 </table>
00350 </center>
00351 </small>
00352 
00353 @} */
00354 
00355 // Xmega A series has AES, EBI and DMA bits
00356 // Include any other device on need basis
00357 #if defined(__AVR_ATxmega16A4__) \
00358 || defined(__AVR_ATxmega32A4__) \
00359 || defined(__AVR_ATxmega64A1__) \
00360 || defined(__AVR_ATxmega64A1U__) \
00361 || defined(__AVR_ATxmega64A3__) \
00362 || defined(__AVR_ATxmega128A1__) \
00363 || defined(__AVR_ATxmega128A1U__) \
00364 || defined(__AVR_ATxmega128A3__) \
00365 || defined(__AVR_ATxmega192A3__) \
00366 || defined(__AVR_ATxmega256A3__) \
00367 || defined(__AVR_ATxmega256A3B__) \
00368 || defined(__AVR_ATxmega256A3BU__)
00369 
00370 #define power_aes_enable()  (PR_PRGEN &= (uint8_t)~(PR_AES_bm))
00371 #define power_aes_disable() (PR_PRGEN |= (uint8_t)PR_AES_bm)
00372 
00373 #define power_ebi_enable()  (PR_PRGEN &= (uint8_t)~(PR_EBI_bm))
00374 #define power_ebi_disable() (PR_PRGEN |= (uint8_t)PR_EBI_bm)
00375 
00376 #define power_dma_enable()    (PR_PRGEN &= (uint8_t)~(PR_DMA_bm))
00377 #define power_dma_disable()   (PR_PRGEN |= (uint8_t)PR_DMA_bm)
00378 
00379 #define power_daca_enable()     (PR_PRPA &= (uint8_t)~(PR_DAC_bm))
00380 #define power_daca_disable()    (PR_PRPA |= (uint8_t)PR_DAC_bm)
00381 #define power_dacb_enable()     (PR_PRPB &= (uint8_t)~(PR_DAC_bm))
00382 #define power_dacb_disable()    (PR_PRPB |= (uint8_t)PR_DAC_bm)
00383 
00384 #define power_usartc1_enable()  (PR_PRPC &= (uint8_t)~(PR_USART1_bm))
00385 #define power_usartc1_disable() (PR_PRPC |= (uint8_t)PR_USART1_bm)
00386 #define power_usartd1_enable()  (PR_PRPD &= (uint8_t)~(PR_USART1_bm))
00387 #define power_usartd1_disable() (PR_PRPD |= (uint8_t)PR_USART1_bm)
00388 #define power_usarte1_enable()  (PR_PRPE &= (uint8_t)~(PR_USART1_bm))
00389 #define power_usarte1_disable() (PR_PRPE |= (uint8_t)PR_USART1_bm)
00390 #define power_usartf1_enable()  (PR_PRPF &= (uint8_t)~(PR_USART1_bm))
00391 #define power_usartf1_disable() (PR_PRPF |= (uint8_t)PR_USART1_bm)
00392 
00393 #if defined(__AVR_ATxmega256A3BU__)
00394 #define power_usb_enable()   (PR_PRGEN &= (uint8_t)~(PR_USB_bm))
00395 #define power_usb_disable()  (PR_PRGEN &= (uint8_t)(PR_USB_bm))
00396 
00397 #define power_all_enable() \
00398 do { \
00399     PR_PRGEN &= (uint8_t)~(PR_AES_bm|PR_EBI_bm|PR_RTC_bm|PR_EVSYS_bm|PR_DMA_bm|PR_USB_bm); \
00400     PR_PRPA &= (uint8_t)~(PR_DAC_bm|PR_ADC_bm|PR_AC_bm); \
00401     PR_PRPB &= (uint8_t)~(PR_DAC_bm|PR_ADC_bm|PR_AC_bm); \
00402     PR_PRPC &= (uint8_t)~(PR_TWI_bm|PR_USART1_bm|PR_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
00403     PR_PRPD &= (uint8_t)~(PR_TWI_bm|PR_USART1_bm|PR_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
00404     PR_PRPE &= (uint8_t)~(PR_TWI_bm|PR_USART1_bm|PR_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
00405     PR_PRPF &= (uint8_t)~(PR_TWI_bm|PR_USART1_bm|PR_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
00406 } while(0)
00407 
00408 #define power_all_disable() \
00409 do { \
00410     PR_PRGEN |= (uint8_t)(PR_AES_bm|PR_EBI_bm|PR_RTC_bm|PR_EVSYS_bm|PR_DMA_bm|PR_USB_bm); \
00411     PR_PRPA |= (uint8_t)(PR_DAC_bm|PR_ADC_bm|PR_AC_bm); \
00412     PR_PRPB |= (uint8_t)(PR_DAC_bm|PR_ADC_bm|PR_AC_bm); \
00413     PR_PRPC |= (uint8_t)(PR_TWI_bm|PR_USART1_bm|PR_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
00414     PR_PRPD |= (uint8_t)(PR_TWI_bm|PR_USART1_bm|PR_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
00415     PR_PRPE |= (uint8_t)(PR_TWI_bm|PR_USART1_bm|PR_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
00416     PR_PRPF |= (uint8_t)(PR_TWI_bm|PR_USART1_bm|PR_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
00417 } while(0)
00418 
00419 #else
00420 
00421 #define power_all_enable() \
00422 do { \
00423     PR_PRGEN &= (uint8_t)~(PR_AES_bm|PR_EBI_bm|PR_RTC_bm|PR_EVSYS_bm|PR_DMA_bm); \
00424     PR_PRPA &= (uint8_t)~(PR_DAC_bm|PR_ADC_bm|PR_AC_bm); \
00425     PR_PRPB &= (uint8_t)~(PR_DAC_bm|PR_ADC_bm|PR_AC_bm); \
00426     PR_PRPC &= (uint8_t)~(PR_TWI_bm|PR_USART1_bm|PR_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
00427     PR_PRPD &= (uint8_t)~(PR_TWI_bm|PR_USART1_bm|PR_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
00428     PR_PRPE &= (uint8_t)~(PR_TWI_bm|PR_USART1_bm|PR_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
00429     PR_PRPF &= (uint8_t)~(PR_TWI_bm|PR_USART1_bm|PR_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
00430 } while(0)
00431 
00432 
00433 #define power_all_disable() \
00434 do { \
00435     PR_PRGEN|= (uint8_t)(PR_AES_bm|PR_EBI_bm|PR_RTC_bm|PR_EVSYS_bm|PR_DMA_bm); \
00436     PR_PRPA |= (uint8_t)(PR_DAC_bm|PR_ADC_bm|PR_AC_bm); \
00437     PR_PRPB |= (uint8_t)(PR_DAC_bm|PR_ADC_bm|PR_AC_bm); \
00438     PR_PRPC |= (uint8_t)(PR_TWI_bm|PR_USART1_bm|PR_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
00439     PR_PRPD |= (uint8_t)(PR_TWI_bm|PR_USART1_bm|PR_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
00440     PR_PRPE |= (uint8_t)(PR_TWI_bm|PR_USART1_bm|PR_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
00441     PR_PRPF |= (uint8_t)(PR_TWI_bm|PR_USART1_bm|PR_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
00442 #endif
00443 
00444 #endif
00445 
00446 #if defined(__AVR_ATxmega16A4__) \
00447 || defined(__AVR_ATxmega16D4__) \
00448 || defined(__AVR_ATxmega32A4__) \
00449 || defined(__AVR_ATxmega32D4__) \
00450 || defined(__AVR_ATxmega32X1__) \
00451 || defined(__AVR_ATxmega64A1__) \
00452 || defined(__AVR_ATxmega64A1U__) \
00453 || defined(__AVR_ATxmega64A3__) \
00454 || defined(__AVR_ATxmega64D3__) \
00455 || defined(__AVR_ATxmega128A1__) \
00456 || defined(__AVR_ATxmega128A1U__) \
00457 || defined(__AVR_ATxmega128A3__) \
00458 || defined(__AVR_ATxmega128D3__) \
00459 || defined(__AVR_ATxmega192A3__) \
00460 || defined(__AVR_ATxmega192D3__) \
00461 || defined(__AVR_ATxmega256A3__) \
00462 || defined(__AVR_ATxmega256A3B__)
00463 
00464 
00465 #define power_rtc_enable()  (PR_PRGEN &= (uint8_t)~(PR_RTC_bm))
00466 #define power_rtc_disable() (PR_PRGEN |= (uint8_t)PR_RTC_bm)
00467 
00468 #define power_evsys_enable()    (PR_PRGEN &= (uint8_t)~(PR_EVSYS_bm))
00469 #define power_evsys_disable()   (PR_PRGEN |= (uint8_t)PR_EVSYS_bm)
00470 
00471 #define power_adca_enable()     (PR_PRPA &= (uint8_t)~(PR_ADC_bm))
00472 #define power_adca_disable()    (PR_PRPA |= (uint8_t)PR_ADC_bm)
00473 #define power_adcb_enable()     (PR_PRPB &= (uint8_t)~(PR_ADC_bm))
00474 #define power_adcb_disable()    (PR_PRPB |= (uint8_t)PR_ADC_bm)
00475 
00476 #define power_aca_enable()      (PR_PRPA &= (uint8_t)~(PR_AC_bm))
00477 #define power_aca_disable()     (PR_PRPA |= (uint8_t)PR_AC_bm)
00478 #define power_acb_enable()      (PR_PRPB &= (uint8_t)~(PR_AC_bm))
00479 #define power_acb_disable()     (PR_PRPB |= (uint8_t)PR_AC_bm)
00480 
00481 #define power_twic_enable()     (PR_PRPC &= (uint8_t)~(PR_TWI_bm))
00482 #define power_twic_disable()    (PR_PRPC |= (uint8_t)PR_TWI_bm)
00483 #define power_twid_enable()     (PR_PRPD &= (uint8_t)~(PR_TWI_bm))
00484 #define power_twid_disable()    (PR_PRPD |= (uint8_t)PR_TWI_bm)
00485 #define power_twie_enable()     (PR_PRPE &= (uint8_t)~(PR_TWI_bm))
00486 #define power_twie_disable()    (PR_PRPE |= (uint8_t)PR_TWI_bm)
00487 #define power_twif_enable()     (PR_PRPF &= (uint8_t)~(PR_TWI_bm))
00488 #define power_twif_disable()    (PR_PRPF |= (uint8_t)PR_TWI_bm)
00489 
00490 #define power_usartc0_enable()  (PR_PRPC &= (uint8_t)~(PR_USART0_bm))
00491 #define power_usartc0_disable() (PR_PRPC |= (uint8_t)PR_USART0_bm)
00492 #define power_usartd0_enable()  (PR_PRPD &= (uint8_t)~(PR_USART0_bm))
00493 #define power_usartd0_disable() (PR_PRPD |= (uint8_t)PR_USART0_bm)
00494 #define power_usarte0_enable()  (PR_PRPE &= (uint8_t)~(PR_USART0_bm))
00495 #define power_usarte0_disable() (PR_PRPE |= (uint8_t)PR_USART0_bm)
00496 #define power_usartf0_enable()  (PR_PRPF &= (uint8_t)~(PR_USART0_bm))
00497 #define power_usartf0_disable() (PR_PRPF |= (uint8_t)PR_USART0_bm)
00498 
00499 #define power_spic_enable()     (PR_PRPC &= (uint8_t)~(PR_SPI_bm))
00500 #define power_spic_disable()    (PR_PRPC |= (uint8_t)PR_SPI_bm)
00501 #define power_spid_enable()     (PR_PRPD &= (uint8_t)~(PR_SPI_bm))
00502 #define power_spid_disable()    (PR_PRPD |= (uint8_t)PR_SPI_bm)
00503 #define power_spie_enable()     (PR_PRPE &= (uint8_t)~(PR_SPI_bm))
00504 #define power_spie_disable()    (PR_PRPE |= (uint8_t)PR_SPI_bm)
00505 #define power_spif_enable()     (PR_PRPF &= (uint8_t)~(PR_SPI_bm))
00506 #define power_spif_disable()    (PR_PRPF |= (uint8_t)PR_SPI_bm)
00507 
00508 #define power_hiresc_enable()   (PR_PRPC &= (uint8_t)~(PR_HIRES_bm))
00509 #define power_hiresc_disable()  (PR_PRPC |= (uint8_t)PR_HIRES_bm)
00510 #define power_hiresd_enable()   (PR_PRPD &= (uint8_t)~(PR_HIRES_bm))
00511 #define power_hiresd_disable()  (PR_PRPD |= (uint8_t)PR_HIRES_bm)
00512 #define power_hirese_enable()   (PR_PRPE &= (uint8_t)~(PR_HIRES_bm))
00513 #define power_hirese_disable()  (PR_PRPE |= (uint8_t)PR_HIRES_bm)
00514 #define power_hiresf_enable()   (PR_PRPF &= (uint8_t)~(PR_HIRES_bm))
00515 #define power_hiresf_disable()  (PR_PRPF |= (uint8_t)PR_HIRES_bm)
00516 
00517 #define power_tc1c_enable()     (PR_PRPC &= (uint8_t)~(PR_TC1_bm))
00518 #define power_tc1c_disable()    (PR_PRPC |= (uint8_t)PR_TC1_bm)
00519 #define power_tc1d_enable()     (PR_PRPD &= (uint8_t)~(PR_TC1_bm))
00520 #define power_tc1d_disable()    (PR_PRPD |= (uint8_t)PR_TC1_bm)
00521 #define power_tc1e_enable()     (PR_PRPE &= (uint8_t)~(PR_TC1_bm))
00522 #define power_tc1e_disable()    (PR_PRPE |= (uint8_t)PR_TC1_bm)
00523 #define power_tc1f_enable()     (PR_PRPF &= (uint8_t)~(PR_TC1_bm))
00524 #define power_tc1f_disable()    (PR_PRPF |= (uint8_t)PR_TC1_bm)
00525 
00526 #define power_tc0c_enable()     (PR_PRPC &= (uint8_t)~(PR_TC0_bm))
00527 #define power_tc0c_disable()    (PR_PRPC |= (uint8_t)PR_TC0_bm)
00528 #define power_tc0d_enable()     (PR_PRPD &= (uint8_t)~(PR_TC0_bm))
00529 #define power_tc0d_disable()    (PR_PRPD |= (uint8_t)PR_TC0_bm)
00530 #define power_tc0e_enable()     (PR_PRPE &= (uint8_t)~(PR_TC0_bm))
00531 #define power_tc0e_disable()    (PR_PRPE |= (uint8_t)PR_TC0_bm)
00532 #define power_tc0f_enable()     (PR_PRPF &= (uint8_t)~(PR_TC0_bm))
00533 #define power_tc0f_disable()    (PR_PRPF |= (uint8_t)PR_TC0_bm)
00534 
00535 #endif
00536 
00537 #if defined(__AVR_ATxmega16D4__) \
00538 || defined(__AVR_ATxmega32D4__) \
00539 || defined(__AVR_ATxmega64D3__) \
00540 || defined(__AVR_ATxmega128D3__) \
00541 || defined(__AVR_ATxmega192D3__) 
00542 
00543 #define power_all_enable() \
00544 do { \
00545     PR_PRGEN &= (uint8_t)~(PR_RTC_bm|PR_EVSYS_bm); \
00546     PR_PRPA &= (uint8_t)~(PR_ADC_bm|PR_AC_bm); \
00547     PR_PRPB &= (uint8_t)~(PR_ADC_bm|PR_AC_bm); \
00548     PR_PRPC &= (uint8_t)~(PR_TWI_bm|PR_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
00549     PR_PRPD &= (uint8_t)~(PR_TWI_bm|PR_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
00550     PR_PRPE &= (uint8_t)~(PR_TWI_bm|PR_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
00551     PR_PRPF &= (uint8_t)~(PR_TWI_bm|PR_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
00552 } while(0)
00553 
00554 
00555 #define power_all_disable() \
00556 do { \
00557     PR_PRGEN|= (uint8_t)(PR_EBI_bm|PR_RTC_bm|PR_EVSYS_bm|PR_DMA_bm); \
00558     PR_PRPA |= (uint8_t)(PR_ADC_bm|PR_AC_bm); \
00559     PR_PRPB |= (uint8_t)(PR_ADC_bm|PR_AC_bm); \
00560     PR_PRPC |= (uint8_t)(PR_TWI_bm|R_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
00561     PR_PRPD |= (uint8_t)(PR_TWI_bm|PR_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
00562     PR_PRPE |= (uint8_t)(PR_TWI_bm|PR_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
00563     PR_PRPF |= (uint8_t)(PR_TWI_bm|PR_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
00564 } while(0)
00565 
00566 #endif
00567 
00568 #if defined (__AVR_ATxmega128B1__)
00569 #define power_lcd_enable()  (PR_PRGEN &= (uint8_t)~(PR_LCD_bm))
00570 #define power_lcd_disable() (PR_PRGEN |= (uint8_t)PR_LCD_bm)
00571 
00572 #define power_usb_enable()  (PR_PRGEN &= (uint8_t)~(PR_USB_bm))
00573 #define power_usb_disable() (PR_PRGEN |= (uint8_t)PR_USB_bm)
00574 
00575 #define power_aes_enable()  (PR_PRGEN &= (uint8_t)~(PR_AES_bm))
00576 #define power_aes_disable() (PR_PRGEN |= (uint8_t)PR_AES_bm)
00577 
00578 #define power_rtc_enable()  (PR_PRGEN &= (uint8_t)~(PR_RTC_bm))
00579 #define power_rtc_disable() (PR_PRGEN |= (uint8_t)PR_RTC_bm)
00580 
00581 #define power_evsys_enable()    (PR_PRGEN &= (uint8_t)~(PR_EVSYS_bm))
00582 #define power_evsys_disable()   (PR_PRGEN |= (uint8_t)PR_EVSYS_bm)
00583 
00584 #define power_dma_enable()    (PR_PRGEN &= (uint8_t)~(PR_DMA_bm))
00585 #define power_dma_disable()   (PR_PRGEN |= (uint8_t)PR_DMA_bm)
00586 
00587 #define power_adca_enable()     (PR_PRPA &= (uint8_t)~(PR_ADC_bm))
00588 #define power_adca_disable()    (PR_PRPA |= (uint8_t)PR_ADC_bm)
00589 #define power_adcb_enable()     (PR_PRPB &= (uint8_t)~(PR_ADC_bm))
00590 #define power_adcb_disable()    (PR_PRPB |= (uint8_t)PR_ADC_bm)
00591 
00592 #define power_aca_enable()      (PR_PRPA &= (uint8_t)~(PR_AC_bm))
00593 #define power_aca_disable()     (PR_PRPA |= (uint8_t)PR_AC_bm)
00594 #define power_acb_enable()      (PR_PRPB &= (uint8_t)~(PR_AC_bm))
00595 #define power_acb_disable()     (PR_PRPB |= (uint8_t)PR_AC_bm)
00596 
00597 #define power_twic_enable()     (PR_PRPC &= (uint8_t)~(PR_TWI_bm))
00598 #define power_twic_disable()    (PR_PRPC |= (uint8_t)PR_TWI_bm)
00599 #define power_twid_enable()     (PR_PRPD &= (uint8_t)~(PR_TWI_bm))
00600 #define power_twid_disable()    (PR_PRPD |= (uint8_t)PR_TWI_bm)
00601 #define power_twie_enable()     (PR_PRPE &= (uint8_t)~(PR_TWI_bm))
00602 #define power_twie_disable()    (PR_PRPE |= (uint8_t)PR_TWI_bm)
00603 #define power_twif_enable()     (PR_PRPF &= (uint8_t)~(PR_TWI_bm))
00604 #define power_twif_disable()    (PR_PRPF |= (uint8_t)PR_TWI_bm)
00605 
00606 #define power_usartc1_enable()  (PR_PRPC &= (uint8_t)~(PR_USART1_bm))
00607 #define power_usartc1_disable() (PR_PRPC |= (uint8_t)PR_USART1_bm)
00608 #define power_usartd1_enable()  (PR_PRPD &= (uint8_t)~(PR_USART1_bm))
00609 #define power_usartd1_disable() (PR_PRPD |= (uint8_t)PR_USART1_bm)
00610 #define power_usarte1_enable()  (PR_PRPE &= (uint8_t)~(PR_USART1_bm))
00611 #define power_usarte1_disable() (PR_PRPE |= (uint8_t)PR_USART1_bm)
00612 #define power_usartf1_enable()  (PR_PRPF &= (uint8_t)~(PR_USART1_bm))
00613 #define power_usartf1_disable() (PR_PRPF |= (uint8_t)PR_USART1_bm)
00614 
00615 #define power_usartc0_enable()  (PR_PRPC &= (uint8_t)~(PR_USART0_bm))
00616 #define power_usartc0_disable() (PR_PRPC |= (uint8_t)PR_USART0_bm)
00617 #define power_usartd0_enable()  (PR_PRPD &= (uint8_t)~(PR_USART0_bm))
00618 #define power_usartd0_disable() (PR_PRPD |= (uint8_t)PR_USART0_bm)
00619 #define power_usarte0_enable()  (PR_PRPE &= (uint8_t)~(PR_USART0_bm))
00620 #define power_usarte0_disable() (PR_PRPE |= (uint8_t)PR_USART0_bm)
00621 #define power_usartf0_enable()  (PR_PRPF &= (uint8_t)~(PR_USART0_bm))
00622 #define power_usartf0_disable() (PR_PRPF |= (uint8_t)PR_USART0_bm)
00623 
00624 #define power_all_enable() \
00625 do { \
00626     PR_PRGEN &= (uint8_t)~(PR_LCD_bm|PR_USB_bm|PR_AES_bm|PR_RTC_bm|PR_EVSYS_bm|PR_DMA_bm); \
00627     PR_PRPA &= (uint8_t)~(PR_ADC_bm|PR_AC_bm); \
00628     PR_PRPB &= (uint8_t)~(PR_ADC_bm|PR_AC_bm); \
00629     PR_PRPC &= (uint8_t)~(PR_TWI_bm|PR_USART1_bm|PR_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
00630     PR_PRPD &= (uint8_t)~(PR_TWI_bm|PR_USART1_bm|PR_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
00631     PR_PRPE &= (uint8_t)~(PR_TWI_bm|PR_USART1_bm|PR_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
00632     PR_PRPF &= (uint8_t)~(PR_TWI_bm|PR_USART1_bm|PR_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
00633     } while(0)
00634 
00635 #define power_all_disable() \
00636 do { \
00637     PR_PRGEN |= (uint8_t)(PR_LCD_bm|PR_USB_bm|PR_AES_bm|PR_RTC_bm|PR_EVSYS_bm|PR_DMA_bm); \
00638     PR_PRPA |= (uint8_t)(PR_ADC_bm|PR_AC_bm); \
00639     PR_PRPB |= (uint8_t)(PR_ADC_bm|PR_AC_bm); \
00640     PR_PRPC |= (uint8_t)(PR_TWI_bm|PR_USART1_bm|PR_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
00641     PR_PRPD |= (uint8_t)(PR_TWI_bm|PR_USART1_bm|PR_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
00642     PR_PRPE |= (uint8_t)(PR_TWI_bm|PR_USART1_bm|PR_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
00643     PR_PRPF |= (uint8_t)(PR_TWI_bm|PR_USART1_bm|PR_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
00644     } while(0)
00645 
00646 #endif
00647 
00648 #elif defined(__AVR_ATmega640__) \
00649 || defined(__AVR_ATmega1280__) \
00650 || defined(__AVR_ATmega1281__) \
00651 || defined(__AVR_ATmega2560__) \
00652 || defined(__AVR_ATmega2561__) 
00653 
00654 #define power_adc_enable()      (PRR0 &= (uint8_t)~(1 << PRADC))
00655 #define power_adc_disable()     (PRR0 |= (uint8_t)(1 << PRADC))
00656 
00657 #define power_spi_enable()      (PRR0 &= (uint8_t)~(1 << PRSPI))
00658 #define power_spi_disable()     (PRR0 |= (uint8_t)(1 << PRSPI))
00659 
00660 #define power_twi_enable()      (PRR0 &= (uint8_t)~(1 << PRTWI))
00661 #define power_twi_disable()     (PRR0 |= (uint8_t)(1 << PRTWI))
00662 
00663 #define power_timer0_enable()   (PRR0 &= (uint8_t)~(1 << PRTIM0))
00664 #define power_timer0_disable()  (PRR0 |= (uint8_t)(1 << PRTIM0))
00665 
00666 #define power_timer1_enable()   (PRR0 &= (uint8_t)~(1 << PRTIM1))
00667 #define power_timer1_disable()  (PRR0 |= (uint8_t)(1 << PRTIM1))
00668 
00669 #define power_timer2_enable()   (PRR0 &= (uint8_t)~(1 << PRTIM2))
00670 #define power_timer2_disable()  (PRR0 |= (uint8_t)(1 << PRTIM2))
00671 
00672 #define power_timer3_enable()   (PRR1 &= (uint8_t)~(1 << PRTIM3))
00673 #define power_timer3_disable()  (PRR1 |= (uint8_t)(1 << PRTIM3))
00674 
00675 #define power_timer4_enable()   (PRR1 &= (uint8_t)~(1 << PRTIM4))
00676 #define power_timer4_disable()  (PRR1 |= (uint8_t)(1 << PRTIM4))
00677 
00678 #define power_timer5_enable()   (PRR1 &= (uint8_t)~(1 << PRTIM5))
00679 #define power_timer5_disable()  (PRR1 |= (uint8_t)(1 << PRTIM5))
00680 
00681 #define power_usart0_enable()   (PRR0 &= (uint8_t)~(1 << PRUSART0))
00682 #define power_usart0_disable()  (PRR0 |= (uint8_t)(1 << PRUSART0))
00683 
00684 #define power_usart1_enable()   (PRR1 &= (uint8_t)~(1 << PRUSART1))
00685 #define power_usart1_disable()  (PRR1 |= (uint8_t)(1 << PRUSART1))
00686 
00687 #define power_usart2_enable()   (PRR1 &= (uint8_t)~(1 << PRUSART2))
00688 #define power_usart2_disable()  (PRR1 |= (uint8_t)(1 << PRUSART2))
00689 
00690 #define power_usart3_enable()   (PRR1 &= (uint8_t)~(1 << PRUSART3))
00691 #define power_usart3_disable()  (PRR1 |= (uint8_t)(1 << PRUSART3))
00692 
00693 #define power_all_enable() \
00694 do{ \
00695     PRR0 &= (uint8_t)~((1<<PRADC)|(1<<PRSPI)|(1<<PRTWI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRTIM2)|(1<<PRUSART0)); \
00696     PRR1 &= (uint8_t)~((1<<PRTIM3)|(1<<PRTIM4)|(1<<PRTIM5)|(1<<PRTIM5)|(1<<PRUSART1)|(1<<PRUSART2)|(1<<PRUSART3)); \
00697 }while(0)
00698 
00699 #define power_all_disable() \
00700 do{ \
00701     PRR0 |= (uint8_t)((1<<PRADC)|(1<<PRSPI)|(1<<PRTWI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRTIM2)|(1<<PRUSART0)); \
00702     PRR1 |= (uint8_t)((1<<PRTIM3)|(1<<PRTIM4)|(1<<PRTIM5)|(1<<PRTIM5)|(1<<PRUSART1)|(1<<PRUSART2)|(1<<PRUSART3)); \
00703 }while(0)
00704 
00705 
00706 #elif defined(__AVR_ATmega128RFA1__)
00707 
00708 #define power_adc_enable()      (PRR0 &= (uint8_t)~(1 << PRADC))
00709 #define power_adc_disable()     (PRR0 |= (uint8_t)(1 << PRADC))
00710 
00711 #define power_spi_enable()      (PRR0 &= (uint8_t)~(1 << PRSPI))
00712 #define power_spi_disable()     (PRR0 |= (uint8_t)(1 << PRSPI))
00713 
00714 #define power_twi_enable()      (PRR0 &= (uint8_t)~(1 << PRTWI))
00715 #define power_twi_disable()     (PRR0 |= (uint8_t)(1 << PRTWI))
00716 
00717 #define power_timer0_enable()   (PRR0 &= (uint8_t)~(1 << PRTIM0))
00718 #define power_timer0_disable()  (PRR0 |= (uint8_t)(1 << PRTIM0))
00719 
00720 #define power_timer1_enable()   (PRR0 &= (uint8_t)~(1 << PRTIM1))
00721 #define power_timer1_disable()  (PRR0 |= (uint8_t)(1 << PRTIM1))
00722 
00723 #define power_timer2_enable()   (PRR0 &= (uint8_t)~(1 << PRTIM2))
00724 #define power_timer2_disable()  (PRR0 |= (uint8_t)(1 << PRTIM2))
00725 
00726 #define power_timer3_enable()   (PRR1 &= (uint8_t)~(1 << PRTIM3))
00727 #define power_timer3_disable()  (PRR1 |= (uint8_t)(1 << PRTIM3))
00728 
00729 #define power_timer4_enable()   (PRR1 &= (uint8_t)~(1 << PRTIM4))
00730 #define power_timer4_disable()  (PRR1 |= (uint8_t)(1 << PRTIM4))
00731 
00732 #define power_timer5_enable()   (PRR1 &= (uint8_t)~(1 << PRTIM5))
00733 #define power_timer5_disable()  (PRR1 |= (uint8_t)(1 << PRTIM5))
00734 
00735 #define power_usart0_enable()   (PRR0 &= (uint8_t)~(1 << PRUSART0))
00736 #define power_usart0_disable()  (PRR0 |= (uint8_t)(1 << PRUSART0))
00737 
00738 #define power_usart1_enable()   (PRR1 &= (uint8_t)~(1 << PRUSART1))
00739 #define power_usart1_disable()  (PRR1 |= (uint8_t)(1 << PRUSART1))
00740 
00741 #define power_all_enable() \
00742 do{ \
00743     PRR0 &= (uint8_t)~((1<<PRADC)|(1<<PRSPI)|(1<<PRTWI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRTIM2)|(1<<PRUSART0)); \
00744     PRR1 &= (uint8_t)~((1<<PRTIM3)|(1<<PRTIM4)|(1<<PRTIM5)|(1<<PRTIM5)|(1<<PRUSART1)); \
00745 }while(0)
00746 
00747 #define power_all_disable() \
00748 do{ \
00749     PRR0 |= (uint8_t)((1<<PRADC)|(1<<PRSPI)|(1<<PRTWI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRTIM2)|(1<<PRUSART0)); \
00750     PRR1 |= (uint8_t)((1<<PRTIM3)|(1<<PRTIM4)|(1<<PRTIM5)|(1<<PRTIM5)|(1<<PRUSART1)); \
00751 }while(0)
00752 
00753 
00754 #elif defined(__AVR_AT90USB646__) \
00755 || defined(__AVR_AT90USB647__) \
00756 || defined(__AVR_AT90USB1286__) \
00757 || defined(__AVR_AT90USB1287__)
00758 
00759 #define power_adc_enable()      (PRR0 &= (uint8_t)~(1 << PRADC))
00760 #define power_adc_disable()     (PRR0 |= (uint8_t)(1 << PRADC))
00761 
00762 #define power_spi_enable()      (PRR0 &= (uint8_t)~(1 << PRSPI))
00763 #define power_spi_disable()     (PRR0 |= (uint8_t)(1 << PRSPI))
00764 
00765 #define power_twi_enable()      (PRR0 &= (uint8_t)~(1 << PRTWI))
00766 #define power_twi_disable()     (PRR0 |= (uint8_t)(1 << PRTWI))
00767 
00768 #define power_timer0_enable()   (PRR0 &= (uint8_t)~(1 << PRTIM0))
00769 #define power_timer0_disable()  (PRR0 |= (uint8_t)(1 << PRTIM0))
00770 
00771 #define power_timer1_enable()   (PRR0 &= (uint8_t)~(1 << PRTIM1))
00772 #define power_timer1_disable()  (PRR0 |= (uint8_t)(1 << PRTIM1))
00773 
00774 #define power_timer2_enable()   (PRR0 &= (uint8_t)~(1 << PRTIM2))
00775 #define power_timer2_disable()  (PRR0 |= (uint8_t)(1 << PRTIM2))
00776 
00777 #define power_timer3_enable()   (PRR1 &= (uint8_t)~(1 << PRTIM3))
00778 #define power_timer3_disable()  (PRR1 |= (uint8_t)(1 << PRTIM3))
00779 
00780 #define power_usart1_enable()   (PRR1 &= (uint8_t)~(1 << PRUSART1))
00781 #define power_usart1_disable()  (PRR1 |= (uint8_t)(1 << PRUSART1))
00782 
00783 #define power_usb_enable()      (PRR1 &= (uint8_t)~(1 << PRUSB))
00784 #define power_usb_disable()     (PRR1 |= (uint8_t)(1 << PRUSB))
00785 
00786 #define power_all_enable() \
00787 do{ \
00788     PRR0 &= (uint8_t)~((1<<PRADC)|(1<<PRSPI)|(1<<PRTWI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRTIM2)); \
00789     PRR1 &= (uint8_t)~((1<<PRTIM3)|(1<<PRUSART1)|(1<<PRUSB)); \
00790 }while(0)
00791 
00792 #define power_all_disable() \
00793 do{ \
00794     PRR0 |= (uint8_t)((1<<PRADC)|(1<<PRSPI)|(1<<PRTWI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRTIM2)); \
00795     PRR1 |= (uint8_t)((1<<PRTIM3)|(1<<PRUSART1)|(1<<PRUSB)); \
00796 }while(0)
00797 
00798 
00799 #elif defined(__AVR_ATmega32U4__) \
00800 || defined(__AVR_ATmega16U4__)
00801 
00802 
00803 #define power_adc_enable()      (PRR0 &= (uint8_t)~(1 << PRADC))
00804 #define power_adc_disable()     (PRR0 |= (uint8_t)(1 << PRADC))
00805 
00806 #define power_usart0_enable()   (PRR0 &= (uint8_t)~(1 << PRUSART0))
00807 #define power_usart0_disable()  (PRR0 |= (uint8_t)(1 << PRUSART0))
00808 
00809 #define power_spi_enable()      (PRR0 &= (uint8_t)~(1 << PRSPI))
00810 #define power_spi_disable()     (PRR0 |= (uint8_t)(1 << PRSPI))
00811 
00812 #define power_twi_enable()      (PRR0 &= (uint8_t)~(1 << PRTWI))
00813 #define power_twi_disable()     (PRR0 |= (uint8_t)(1 << PRTWI))
00814 
00815 #define power_timer0_enable()   (PRR0 &= (uint8_t)~(1 << PRTIM0))
00816 #define power_timer0_disable()  (PRR0 |= (uint8_t)(1 << PRTIM0))
00817 
00818 #define power_timer1_enable()   (PRR0 &= (uint8_t)~(1 << PRTIM1))
00819 #define power_timer1_disable()  (PRR0 |= (uint8_t)(1 << PRTIM1))
00820 
00821 #define power_timer2_enable()   (PRR0 &= (uint8_t)~(1 << PRTIM2))
00822 #define power_timer2_disable()  (PRR0 |= (uint8_t)(1 << PRTIM2))
00823 
00824 #define power_timer3_enable()   (PRR1 &= (uint8_t)~(1 << PRTIM3))
00825 #define power_timer3_disable()  (PRR1 |= (uint8_t)(1 << PRTIM3))
00826 
00827 #define power_usart1_enable()   (PRR1 &= (uint8_t)~(1 << PRUSART1))
00828 #define power_usart1_disable()  (PRR1 |= (uint8_t)(1 << PRUSART1))
00829 
00830 #define power_usb_enable()      (PRR1 &= (uint8_t)~(1 << PRUSB))
00831 #define power_usb_disable()     (PRR1 |= (uint8_t)(1 << PRUSB))
00832 
00833 #define power_all_enable() \
00834 do{ \
00835     PRR0 &= (uint8_t)~((1<<PRADC)|(1<<PRUSART0)|(1<<PRSPI)|(1<<PRTWI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRTIM2)); \
00836     PRR1 &= (uint8_t)~((1<<PRTIM3)|(1<<PRUSART1)|(1<<PRUSB)); \
00837 }while(0)
00838 
00839 #define power_all_disable() \
00840 do{ \
00841     PRR0 |= (uint8_t)((1<<PRADC)|(1<<PRUSART0)|(1<<PRSPI)|(1<<PRTWI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRTIM2)); \
00842     PRR1 |= (uint8_t)((1<<PRTIM3)|(1<<PRUSART1)|(1<<PRUSB)); \
00843 }while(0)
00844 
00845 
00846 #elif defined(__AVR_ATmega32U6__)
00847 
00848 
00849 #define power_adc_enable()      (PRR0 &= (uint8_t)~(1 << PRADC))
00850 #define power_adc_disable()     (PRR0 |= (uint8_t)(1 << PRADC))
00851 
00852 #define power_spi_enable()      (PRR0 &= (uint8_t)~(1 << PRSPI))
00853 #define power_spi_disable()     (PRR0 |= (uint8_t)(1 << PRSPI))
00854 
00855 #define power_twi_enable()      (PRR0 &= (uint8_t)~(1 << PRTWI))
00856 #define power_twi_disable()     (PRR0 |= (uint8_t)(1 << PRTWI))
00857 
00858 #define power_timer0_enable()   (PRR0 &= (uint8_t)~(1 << PRTIM0))
00859 #define power_timer0_disable()  (PRR0 |= (uint8_t)(1 << PRTIM0))
00860 
00861 #define power_timer1_enable()   (PRR0 &= (uint8_t)~(1 << PRTIM1))
00862 #define power_timer1_disable()  (PRR0 |= (uint8_t)(1 << PRTIM1))
00863 
00864 #define power_timer2_enable()   (PRR0 &= (uint8_t)~(1 << PRTIM2))
00865 #define power_timer2_disable()  (PRR0 |= (uint8_t)(1 << PRTIM2))
00866 
00867 #define power_timer3_enable()   (PRR1 &= (uint8_t)~(1 << PRTIM3))
00868 #define power_timer3_disable()  (PRR1 |= (uint8_t)(1 << PRTIM3))
00869 
00870 #define power_usart1_enable()   (PRR1 &= (uint8_t)~(1 << PRUSART1))
00871 #define power_usart1_disable()  (PRR1 |= (uint8_t)(1 << PRUSART1))
00872 
00873 #define power_usb_enable()      (PRR1 &= (uint8_t)~(1 << PRUSB))
00874 #define power_usb_disable()     (PRR1 |= (uint8_t)(1 << PRUSB))
00875 
00876 #define power_all_enable() \
00877 do{ \
00878     PRR0 &= (uint8_t)~((1<<PRADC)|(1<<PRSPI)|(1<<PRTWI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRTIM2)); \
00879     PRR1 &= (uint8_t)~((1<<PRTIM3)|(1<<PRUSART1)|(1<<PRUSB)); \
00880 }while(0)
00881 
00882 #define power_all_disable() \
00883 do{ \
00884     PRR0 |= (uint8_t)((1<<PRADC)|(1<<PRSPI)|(1<<PRTWI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRTIM2)); \
00885     PRR1 |= (uint8_t)((1<<PRTIM3)|(1<<PRUSART1)|(1<<PRUSB)); \
00886 }while(0)
00887 
00888 
00889 #elif defined(__AVR_AT90PWM1__)
00890 
00891 #define power_adc_enable()      (PRR &= (uint8_t)~(1 << PRADC))
00892 #define power_adc_disable()     (PRR |= (uint8_t)(1 << PRADC))
00893 
00894 #define power_spi_enable()      (PRR &= (uint8_t)~(1 << PRSPI))
00895 #define power_spi_disable()     (PRR |= (uint8_t)(1 << PRSPI))
00896 
00897 #define power_timer0_enable()   (PRR &= (uint8_t)~(1 << PRTIM0))
00898 #define power_timer0_disable()  (PRR |= (uint8_t)(1 << PRTIM0))
00899 
00900 #define power_timer1_enable()   (PRR &= (uint8_t)~(1 << PRTIM1))
00901 #define power_timer1_disable()  (PRR |= (uint8_t)(1 << PRTIM1))
00902 
00903 /* Power Stage Controller 0 */
00904 #define power_psc0_enable()     (PRR &= (uint8_t)~(1 << PRPSC0))
00905 #define power_psc0_disable()    (PRR |= (uint8_t)(1 << PRPSC0))
00906 
00907 /* Power Stage Controller 1 */
00908 #define power_psc1_enable()     (PRR &= (uint8_t)~(1 << PRPSC1))
00909 #define power_psc1_disable()    (PRR |= (uint8_t)(1 << PRPSC1))
00910 
00911 /* Power Stage Controller 2 */
00912 #define power_psc2_enable()     (PRR &= (uint8_t)~(1 << PRPSC2))
00913 #define power_psc2_disable()    (PRR |= (uint8_t)(1 << PRPSC2))
00914 
00915 #define power_all_enable()      (PRR &= (uint8_t)~((1<<PRADC)|(1<<PRSPI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRPSC0)|(1<<PRPSC1)|(1<<PRPSC2)))
00916 #define power_all_disable()     (PRR |= (uint8_t)((1<<PRADC)|(1<<PRSPI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRPSC0)|(1<<PRPSC1)|(1<<PRPSC2)))
00917 
00918 
00919 #elif defined(__AVR_AT90PWM2__) \
00920 || defined(__AVR_AT90PWM2B__) \
00921 || defined(__AVR_AT90PWM3__) \
00922 || defined(__AVR_AT90PWM3B__) \
00923 || defined(__AVR_AT90PWM216__) \
00924 || defined(__AVR_AT90PWM316__)
00925 
00926 #define power_adc_enable()      (PRR &= (uint8_t)~(1 << PRADC))
00927 #define power_adc_disable()     (PRR |= (uint8_t)(1 << PRADC))
00928 
00929 #define power_spi_enable()      (PRR &= (uint8_t)~(1 << PRSPI))
00930 #define power_spi_disable()     (PRR |= (uint8_t)(1 << PRSPI))
00931 
00932 #define power_usart_enable()    (PRR &= (uint8_t)~(1 << PRUSART))
00933 #define power_usart_disable()   (PRR |= (uint8_t)(1 << PRUSART))
00934 
00935 #define power_timer0_enable()   (PRR &= (uint8_t)~(1 << PRTIM0))
00936 #define power_timer0_disable()  (PRR |= (uint8_t)(1 << PRTIM0))
00937 
00938 #define power_timer1_enable()   (PRR &= (uint8_t)~(1 << PRTIM1))
00939 #define power_timer1_disable()  (PRR |= (uint8_t)(1 << PRTIM1))
00940 
00941 /* Power Stage Controller 0 */
00942 #define power_psc0_enable()     (PRR &= (uint8_t)~(1 << PRPSC0))
00943 #define power_psc0_disable()    (PRR |= (uint8_t)(1 << PRPSC0))
00944 
00945 /* Power Stage Controller 1 */
00946 #define power_psc1_enable()     (PRR &= (uint8_t)~(1 << PRPSC1))
00947 #define power_psc1_disable()    (PRR |= (uint8_t)(1 << PRPSC1))
00948 
00949 /* Power Stage Controller 2 */
00950 #define power_psc2_enable()     (PRR &= (uint8_t)~(1 << PRPSC2))
00951 #define power_psc2_disable()    (PRR |= (uint8_t)(1 << PRPSC2))
00952 
00953 #define power_all_enable()      (PRR &= (uint8_t)~((1<<PRADC)|(1<<PRSPI)|(1<<PRUSART)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRPSC0)|(1<<PRPSC1)|(1<<PRPSC2)))
00954 #define power_all_disable()     (PRR |= (uint8_t)((1<<PRADC)|(1<<PRSPI)|(1<<PRUSART)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRPSC0)|(1<<PRPSC1)|(1<<PRPSC2)))
00955 
00956 
00957 #elif defined(__AVR_AT90PWM81__) \
00958 || defined(__AVR_AT90PWM161__)
00959 
00960 #define power_adc_enable()      (PRR &= (uint8_t)~(1 << PRADC))
00961 #define power_adc_disable()     (PRR |= (uint8_t)(1 << PRADC))
00962 
00963 #define power_spi_enable()      (PRR &= (uint8_t)~(1 << PRSPI))
00964 #define power_spi_disable()     (PRR |= (uint8_t)(1 << PRSPI))
00965 
00966 #define power_timer1_enable()   (PRR &= (uint8_t)~(1 << PRTIM1))
00967 #define power_timer1_disable()  (PRR |= (uint8_t)(1 << PRTIM1))
00968 
00969 /* Reduced Power Stage Controller */
00970 #define power_pscr_enable()     (PRR &= (uint8_t)~(1 << PRPSCR))
00971 #define power_pscr_disable()    (PRR |= (uint8_t)(1 << PRPSCR))
00972 
00973 /* Power Stage Controller 2 */
00974 #define power_psc2_enable()     (PRR &= (uint8_t)~(1 << PRPSC2))
00975 #define power_psc2_disable()    (PRR |= (uint8_t)(1 << PRPSC2))
00976 
00977 #define power_all_enable()      (PRR &= (uint8_t)~((1<<PRADC)|(1<<PRSPI)|(1<<PRTIM1)|(1<<PRPSCR)|(1<<PRPSC2)))
00978 #define power_all_disable()     (PRR |= (uint8_t)((1<<PRADC)|(1<<PRSPI)|(1<<PRTIM1)|(1<<PRPSCR)|(1<<PRPSC2)))
00979 
00980 
00981 #elif defined(__AVR_ATmega165__) \
00982 || defined(__AVR_ATmega165A__) \
00983 || defined(__AVR_ATmega165P__) \
00984 || defined(__AVR_ATmega325__) \
00985 || defined(__AVR_ATmega325A__) \
00986 || defined(__AVR_ATmega325PA__) \
00987 || defined(__AVR_ATmega3250__) \
00988 || defined(__AVR_ATmega3250A__) \
00989 || defined(__AVR_ATmega3250PA__) \
00990 || defined(__AVR_ATmega645__) \
00991 || defined(__AVR_ATmega645A__) \
00992 || defined(__AVR_ATmega645P__) \
00993 || defined(__AVR_ATmega6450__) \
00994 || defined(__AVR_ATmega6450A__) \
00995 || defined(__AVR_ATmega6450P__)
00996 
00997 #define power_adc_enable()      (PRR &= (uint8_t)~(1 << PRADC))
00998 #define power_adc_disable()     (PRR |= (uint8_t)(1 << PRADC))
00999 
01000 #define power_spi_enable()      (PRR &= (uint8_t)~(1 << PRSPI))
01001 #define power_spi_disable()     (PRR |= (uint8_t)(1 << PRSPI))
01002 
01003 #define power_usart0_enable()   (PRR &= (uint8_t)~(1 << PRUSART0))
01004 #define power_usart0_disable()  (PRR |= (uint8_t)(1 << PRUSART0))
01005 
01006 #define power_timer1_enable()   (PRR &= (uint8_t)~(1 << PRTIM1))
01007 #define power_timer1_disable()  (PRR |= (uint8_t)(1 << PRTIM1))
01008 
01009 #define power_all_enable()      (PRR &= (uint8_t)~((1<<PRADC)|(1<<PRSPI)|(1<<PRUSART0)|(1<<PRTIM1)))
01010 #define power_all_disable()     (PRR |= (uint8_t)((1<<PRADC)|(1<<PRSPI)|(1<<PRUSART0)|(1<<PRTIM1)))
01011 
01012 
01013 #elif defined(__AVR_ATmega169__) \
01014 || defined(__AVR_ATmega169A__) \
01015 || defined(__AVR_ATmega169P__) \
01016 || defined(__AVR_ATmega169PA__) \
01017 || defined(__AVR_ATmega329__) \
01018 || defined(__AVR_ATmega329A__) \
01019 || defined(__AVR_ATmega329P__) \
01020 || defined(__AVR_ATmega329PA__) \
01021 || defined(__AVR_ATmega3290__) \
01022 || defined(__AVR_ATmega3290A__) \
01023 || defined(__AVR_ATmega3290P__) \
01024 || defined(__AVR_ATmega3290PA__) \
01025 || defined(__AVR_ATmega649__) \
01026 || defined(__AVR_ATmega649A__) \
01027 || defined(__AVR_ATmega649P__) \
01028 || defined(__AVR_ATmega6490__) \
01029 || defined(__AVR_ATmega6490A__) \
01030 || defined(__AVR_ATmega6490P__)
01031 
01032 #define power_adc_enable()      (PRR &= (uint8_t)~(1 << PRADC))
01033 #define power_adc_disable()     (PRR |= (uint8_t)(1 << PRADC))
01034 
01035 #define power_spi_enable()      (PRR &= (uint8_t)~(1 << PRSPI))
01036 #define power_spi_disable()     (PRR |= (uint8_t)(1 << PRSPI))
01037 
01038 #define power_usart0_enable()   (PRR &= (uint8_t)~(1 << PRUSART0))
01039 #define power_usart0_disable()  (PRR |= (uint8_t)(1 << PRUSART0))
01040 
01041 #define power_timer1_enable()   (PRR &= (uint8_t)~(1 << PRTIM1))
01042 #define power_timer1_disable()  (PRR |= (uint8_t)(1 << PRTIM1))
01043 
01044 #define power_lcd_enable()      (PRR &= (uint8_t)~(1 << PRLCD))
01045 #define power_lcd_disable()     (PRR |= (uint8_t)(1 << PRLCD))
01046 
01047 #define power_all_enable()      (PRR &= (uint8_t)~((1<<PRADC)|(1<<PRSPI)|(1<<PRUSART0)|(1<<PRTIM1)|(1<<PRLCD)))
01048 #define power_all_disable()     (PRR |= (uint8_t)((1<<PRADC)|(1<<PRSPI)|(1<<PRUSART0)|(1<<PRTIM1)|(1<<PRLCD)))
01049 
01050 
01051 #elif defined(__AVR_ATmega164A__) \
01052 || defined(__AVR_ATmega164P__) \
01053 || defined(__AVR_ATmega324A__) \
01054 || defined(__AVR_ATmega324P__) \
01055 || defined(__AVR_ATmega324PA__) \
01056 || defined(__AVR_ATmega644P__) \
01057 || defined(__AVR_ATmega644A__) \
01058 || defined(__AVR_ATmega644PA__)
01059 
01060 #define power_adc_enable()      (PRR0 &= (uint8_t)~(1 << PRADC))
01061 #define power_adc_disable()     (PRR0 |= (uint8_t)(1 << PRADC))
01062 
01063 #define power_spi_enable()      (PRR0 &= (uint8_t)~(1 << PRSPI))
01064 #define power_spi_disable()     (PRR0 |= (uint8_t)(1 << PRSPI))
01065 
01066 #define power_usart0_enable()   (PRR0 &= (uint8_t)~(1 << PRUSART0))
01067 #define power_usart0_disable()  (PRR0 |= (uint8_t)(1 << PRUSART0))
01068 
01069 #define power_usart1_enable()   (PRR0 &= (uint8_t)~(1 << PRUSART1))
01070 #define power_usart1_disable()  (PRR0 |= (uint8_t)(1 << PRUSART1))
01071 
01072 #define power_timer0_enable()   (PRR0 &= (uint8_t)~(1 << PRTIM0))
01073 #define power_timer0_disable()  (PRR0 |= (uint8_t)(1 << PRTIM0))
01074 
01075 #define power_timer1_enable()   (PRR0 &= (uint8_t)~(1 << PRTIM1))
01076 #define power_timer1_disable()  (PRR0 |= (uint8_t)(1 << PRTIM1))
01077 
01078 #define power_timer2_enable()   (PRR0 &= (uint8_t)~(1 << PRTIM2))
01079 #define power_timer2_disable()  (PRR0 |= (uint8_t)(1 << PRTIM2))
01080 
01081 #define power_twi_enable()      (PRR0 &= (uint8_t)~(1 << PRTWI))
01082 #define power_twi_disable()     (PRR0 |= (uint8_t)(1 << PRTWI))
01083 
01084 #define power_all_enable()      (PRR0 &= (uint8_t)~((1<<PRADC)|(1<<PRSPI)|(1<<PRUSART0)|(1<<PRUSART1)|(1<<PRTIM0)|(1<<PRTIM2)|(1<<PRTWI)))
01085 #define power_all_disable()     (PRR0 |= (uint8_t)((1<<PRADC)|(1<<PRSPI)|(1<<PRUSART0)|(1<<PRUSART1)|(1<<PRTIM0)|(1<<PRTIM2)|(1<<PRTWI)))
01086 
01087 
01088 #elif defined(__AVR_ATmega644__)
01089 
01090 #define power_adc_enable()      (PRR0 &= (uint8_t)~(1 << PRADC))
01091 #define power_adc_disable()     (PRR0 |= (uint8_t)(1 << PRADC))
01092 
01093 #define power_spi_enable()      (PRR0 &= (uint8_t)~(1 << PRSPI))
01094 #define power_spi_disable()     (PRR0 |= (uint8_t)(1 << PRSPI))
01095 
01096 #define power_usart0_enable()   (PRR0 &= (uint8_t)~(1 << PRUSART0))
01097 #define power_usart0_disable()  (PRR0 |= (uint8_t)(1 << PRUSART0))
01098 
01099 #define power_timer0_enable()   (PRR0 &= (uint8_t)~(1 << PRTIM0))
01100 #define power_timer0_disable()  (PRR0 |= (uint8_t)(1 << PRTIM0))
01101 
01102 #define power_timer1_enable()   (PRR0 &= (uint8_t)~(1 << PRTIM1))
01103 #define power_timer1_disable()  (PRR0 |= (uint8_t)(1 << PRTIM1))
01104 
01105 #define power_timer2_enable()   (PRR0 &= (uint8_t)~(1 << PRTIM2))
01106 #define power_timer2_disable()  (PRR0 |= (uint8_t)(1 << PRTIM2))
01107 
01108 #define power_twi_enable()      (PRR0 &= (uint8_t)~(1 << PRTWI))
01109 #define power_twi_disable()     (PRR0 |= (uint8_t)(1 << PRTWI))
01110 
01111 #define power_all_enable()      (PRR0 &= (uint8_t)~((1<<PRADC)|(1<<PRSPI)|(1<<PRUSART0)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRTIM2)|(1<<PRTWI)))
01112 #define power_all_disable()     (PRR0 |= (uint8_t)((1<<PRADC)|(1<<PRSPI)|(1<<PRUSART0)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRTIM2)|(1<<PRTWI)))
01113 
01114 
01115 #elif defined(__AVR_ATmega406__)
01116 
01117 #define power_twi_enable()      (PRR0 &= (uint8_t)~(1 << PRTWI))
01118 #define power_twi_disable()     (PRR0 |= (uint8_t)(1 << PRTWI))
01119 
01120 #define power_timer0_enable()   (PRR0 &= (uint8_t)~(1 << PRTIM0))
01121 #define power_timer0_disable()  (PRR0 |= (uint8_t)(1 << PRTIM0))
01122 
01123 #define power_timer1_enable()   (PRR0 &= (uint8_t)~(1 << PRTIM1))
01124 #define power_timer1_disable()  (PRR0 |= (uint8_t)(1 << PRTIM1))
01125 
01126 /* Voltage ADC */
01127 #define power_vadc_enable()     (PRR0 &= (uint8_t)~(1 << PRVADC))
01128 #define power_vadc_disable()    (PRR0 |= (uint8_t)(1 << PRVADC))
01129 
01130 #define power_all_enable()      (PRR0 &= (uint8_t)~((1<<PRTWI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRVADC)))
01131 #define power_all_disable()     (PRR0 |= (uint8_t)((1<<PRTWI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRVADC)))
01132 
01133 
01134 #elif defined(__AVR_ATmega48__) \
01135 || defined(__AVR_ATmega48A__) \
01136 || defined(__AVR_ATmega48P__) \
01137 || defined(__AVR_ATmega88__) \
01138 || defined(__AVR_ATmega88A__) \
01139 || defined(__AVR_ATmega88P__) \
01140 || defined(__AVR_ATmega88PA__) \
01141 || defined(__AVR_ATmega168__) \
01142 || defined(__AVR_ATmega168A__) \
01143 || defined(__AVR_ATmega168P__) \
01144 || defined(__AVR_ATmega328__) \
01145 || defined(__AVR_ATmega328P__) \
01146 || defined(__AVR_ATtiny48__) \
01147 || defined(__AVR_ATtiny88__)
01148 
01149 #define power_adc_enable()      (PRR &= (uint8_t)~(1 << PRADC))
01150 #define power_adc_disable()     (PRR |= (uint8_t)(1 << PRADC))
01151 
01152 #define power_spi_enable()      (PRR &= (uint8_t)~(1 << PRSPI))
01153 #define power_spi_disable()     (PRR |= (uint8_t)(1 << PRSPI))
01154 
01155 #define power_usart0_enable()   (PRR &= (uint8_t)~(1 << PRUSART0))
01156 #define power_usart0_disable()  (PRR |= (uint8_t)(1 << PRUSART0))
01157 
01158 #define power_timer0_enable()   (PRR &= (uint8_t)~(1 << PRTIM0))
01159 #define power_timer0_disable()  (PRR |= (uint8_t)(1 << PRTIM0))
01160 
01161 #define power_timer1_enable()   (PRR &= (uint8_t)~(1 << PRTIM1))
01162 #define power_timer1_disable()  (PRR |= (uint8_t)(1 << PRTIM1))
01163 
01164 #define power_timer2_enable()   (PRR &= (uint8_t)~(1 << PRTIM2))
01165 #define power_timer2_disable()  (PRR |= (uint8_t)(1 << PRTIM2))
01166 
01167 #define power_twi_enable()      (PRR &= (uint8_t)~(1 << PRTWI))
01168 #define power_twi_disable()     (PRR |= (uint8_t)(1 << PRTWI))
01169 
01170 #define power_all_enable()      (PRR &= (uint8_t)~((1<<PRADC)|(1<<PRSPI)|(1<<PRUSART0)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRTIM2)|(1<<PRTWI)))
01171 #define power_all_disable()     (PRR |= (uint8_t)((1<<PRADC)|(1<<PRSPI)|(1<<PRUSART0)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRTIM2)|(1<<PRTWI)))
01172 
01173 
01174 #elif defined(__AVR_ATtiny24__) \
01175 || defined(__AVR_ATtiny24A__) \
01176 || defined(__AVR_ATtiny44__) \
01177 || defined(__AVR_ATtiny44A__) \
01178 || defined(__AVR_ATtiny84__) \
01179 || defined(__AVR_ATtiny84A__) \
01180 || defined(__AVR_ATtiny25__) \
01181 || defined(__AVR_ATtiny45__) \
01182 || defined(__AVR_ATtiny85__) \
01183 || defined(__AVR_ATtiny261__) \
01184 || defined(__AVR_ATtiny261A__) \
01185 || defined(__AVR_ATtiny461__) \
01186 || defined(__AVR_ATtiny461A__) \
01187 || defined(__AVR_ATtiny861__) \
01188 || defined(__AVR_ATtiny861A__) \
01189 || defined(__AVR_ATtiny43U__)
01190 
01191 #define power_adc_enable()      (PRR &= (uint8_t)~(1 << PRADC))
01192 #define power_adc_disable()     (PRR |= (uint8_t)(1 << PRADC))
01193 
01194 #define power_timer0_enable()   (PRR &= (uint8_t)~(1 << PRTIM0))
01195 #define power_timer0_disable()  (PRR |= (uint8_t)(1 << PRTIM0))
01196 
01197 #define power_timer1_enable()   (PRR &= (uint8_t)~(1 << PRTIM1))
01198 #define power_timer1_disable()  (PRR |= (uint8_t)(1 << PRTIM1))
01199 
01200 /* Universal Serial Interface */
01201 #define power_usi_enable()      (PRR &= (uint8_t)~(1 << PRUSI))
01202 #define power_usi_disable()     (PRR |= (uint8_t)(1 << PRUSI))
01203 
01204 #define power_all_enable()      (PRR &= (uint8_t)~((1<<PRADC)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRUSI)))
01205 #define power_all_disable()     (PRR |= (uint8_t)((1<<PRADC)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRUSI)))
01206 
01207 
01208 #elif defined(__AVR_ATmega1284P__)
01209 
01210 
01211 #define power_adc_enable()      (PRR0 &= (uint8_t)~(1 << PRADC))
01212 #define power_adc_disable()     (PRR0 |= (uint8_t)(1 << PRADC))
01213 
01214 #define power_spi_enable()      (PRR0 &= (uint8_t)~(1 << PRSPI))
01215 #define power_spi_disable()     (PRR0 |= (uint8_t)(1 << PRSPI))
01216 
01217 #define power_twi_enable()      (PRR0 &= (uint8_t)~(1 << PRTWI))
01218 #define power_twi_disable()     (PRR0 |= (uint8_t)(1 << PRTWI))
01219 
01220 #define power_timer0_enable()   (PRR0 &= (uint8_t)~(1 << PRTIM0))
01221 #define power_timer0_disable()  (PRR0 |= (uint8_t)(1 << PRTIM0))
01222 
01223 #define power_timer1_enable()   (PRR0 &= (uint8_t)~(1 << PRTIM1))
01224 #define power_timer1_disable()  (PRR0 |= (uint8_t)(1 << PRTIM1))
01225 
01226 #define power_timer2_enable()   (PRR0 &= (uint8_t)~(1 << PRTIM2))
01227 #define power_timer2_disable()  (PRR0 |= (uint8_t)(1 << PRTIM2))
01228 
01229 #define power_timer3_enable()   (PRR1 &= (uint8_t)~(1 << PRTIM3))
01230 #define power_timer3_disable()  (PRR1 |= (uint8_t)(1 << PRTIM3))
01231 
01232 #define power_usart0_enable()   (PRR0 &= (uint8_t)~(1 << PRUSART0))
01233 #define power_usart0_disable()  (PRR0 |= (uint8_t)(1 << PRUSART0))
01234 
01235 #define power_usart1_enable()   (PRR0 &= (uint8_t)~(1 << PRUSART1))
01236 #define power_usart1_disable()  (PRR0 |= (uint8_t)(1 << PRUSART1))
01237 
01238 #define power_all_enable() \
01239 do{ \
01240     PRR0 &= (uint8_t)~((1<<PRADC)|(1<<PRSPI)|(1<<PRTWI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRTIM2)|(1<<PRUSART0)|(1<<PRUSART1)); \
01241     PRR1 &= (uint8_t)~(1<<PRTIM3); \
01242 }while(0)
01243 
01244 #define power_all_disable() \
01245 do{ \
01246     PRR0 |= (uint8_t)((1<<PRADC)|(1<<PRSPI)|(1<<PRTWI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRTIM2)|(1<<PRUSART0)|(1<<PRUSART1)); \
01247     PRR1 |= (uint8_t)(1<<PRTIM3); \
01248 }while(0)
01249 
01250 
01251 #elif defined(__AVR_ATmega32HVB__) \
01252 || defined(__AVR_ATmega32HVBREVB__) \
01253 || defined(__AVR_ATmega16HVB__) \
01254 || defined(__AVR_ATmega16HVBREVB__)
01255 
01256 
01257 #define power_twi_enable()      (PRR0 &= (uint8_t)~(1 << PRTWI))
01258 #define power_twi_disable()     (PRR0 |= (uint8_t)(1 << PRTWI))
01259 
01260 #define power_timer0_enable()   (PRR0 &= (uint8_t)~(1 << PRTIM0))
01261 #define power_timer0_disable()  (PRR0 |= (uint8_t)(1 << PRTIM0))
01262 
01263 #define power_timer1_enable()   (PRR0 &= (uint8_t)~(1 << PRTIM1))
01264 #define power_timer1_disable()  (PRR0 |= (uint8_t)(1 << PRTIM1))
01265 
01266 /* Voltage ADC */
01267 #define power_vadc_enable()     (PRR0 &= (uint8_t)~(1 << PRVADC))
01268 #define power_vadc_disable()    (PRR0 |= (uint8_t)(1 << PRVADC))
01269 
01270 #define power_spi_enable()      (PRR0 &= (uint8_t)~(1 << PRSPI))
01271 #define power_spi_disable()     (PRR0 |= (uint8_t)(1 << PRSPI))
01272 
01273 #define power_vrm_enable()      (PRR0 &= (uint8_t)~(1 << PRVRM))
01274 #define power_vrm_disable()     (PRR0 |= (uint8_t)(1 << PRVRM))
01275 
01276 #define power_all_enable()      (PRR0 &= (uint8_t)~((1<<PRTWI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRVADC)|(1<<PRSPI)|(1<<PRVRM)))
01277 #define power_all_disable()     (PRR0 |= (uint8_t)((1<<PRTWI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRVADC)|(1<<PRSPI)|(1<<PRVRM)))
01278 
01279 
01280 #elif defined(__AVR_ATmega16M1__) \
01281 || defined(__AVR_ATmega32C1__) \
01282 || defined(__AVR_ATmega32M1__) \
01283 || defined(__AVR_ATmega64C1__) \
01284 || defined(__AVR_ATmega64M1__)
01285 
01286 #define power_adc_enable()      (PRR &= (uint8_t)~(1 << PRADC))
01287 #define power_adc_disable()     (PRR |= (uint8_t)(1 << PRADC))
01288 
01289 #define power_lin_enable()      (PRR &= (uint8_t)~(1 << PRLIN))
01290 #define power_lin_disable()     (PRR |= (uint8_t)(1 << PRLIN))
01291 
01292 #define power_spi_enable()      (PRR &= (uint8_t)~(1 << PRSPI))
01293 #define power_spi_disable()     (PRR |= (uint8_t)(1 << PRSPI))
01294 
01295 #define power_timer0_enable()   (PRR &= (uint8_t)~(1 << PRTIM0))
01296 #define power_timer0_disable()  (PRR |= (uint8_t)(1 << PRTIM0))
01297 
01298 #define power_timer1_enable()   (PRR &= (uint8_t)~(1 << PRTIM1))
01299 #define power_timer1_disable()  (PRR |= (uint8_t)(1 << PRTIM1))
01300 
01301 #define power_psc_enable()      (PRR &= (uint8_t)~(1 << PRPSC))
01302 #define power_psc_disable()     (PRR |= (uint8_t)(1 << PRPSC))
01303 
01304 #define power_can_enable()      (PRR &= (uint8_t)~(1 << PRCAN))
01305 #define power_can_disable()     (PRR |= (uint8_t)(1 << PRCAN))
01306 
01307 #define power_all_enable()      (PRR &= (uint8_t)~((1<<PRADC)|(1<<PRLIN)|(1<<PRSPI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRPSC)|(1<<PRCAN)))
01308 #define power_all_disable()     (PRR |= (uint8_t)((1<<PRADC)|(1<<PRLIN)|(1<<PRSPI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRPSC)|(1<<PRCAN)))
01309 
01310 
01311 #elif defined(__AVR_ATtiny167__) \
01312 || defined(__AVR_ATtiny87__)
01313 
01314 
01315 #define power_adc_enable()      (PRR &= (uint8_t)~(1 << PRADC))
01316 #define power_adc_disable()     (PRR |= (uint8_t)(1 << PRADC))
01317 
01318 #define power_usi_enable()      (PRR &= (uint8_t)~(1 << PRUSI))
01319 #define power_usi_disable()     (PRR |= (uint8_t)(1 << PRUSI))
01320 
01321 #define power_timer0_enable()   (PRR &= (uint8_t)~(1 << PRTIM0))
01322 #define power_timer0_disable()  (PRR |= (uint8_t)(1 << PRTIM0))
01323 
01324 #define power_timer1_enable()   (PRR &= (uint8_t)~(1 << PRTIM1))
01325 #define power_timer1_disable()  (PRR |= (uint8_t)(1 << PRTIM1))
01326 
01327 #define power_spi_enable()      (PRR &= (uint8_t)~(1 << PRSPI))
01328 #define power_spi_disable()     (PRR |= (uint8_t)(1 << PRSPI))
01329 
01330 #define power_lin_enable()      (PRR &= (uint8_t)~(1 << PRLIN))
01331 #define power_lin_disable()     (PRR |= (uint8_t)(1 << PRLIN))
01332 
01333 #define power_all_enable()      (PRR &= (uint8_t)~((1<<PRADC)|(1<<PRUSI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRSPI)|(1<<PRLIN)))
01334 #define power_all_disable()     (PRR |= (uint8_t)((1<<PRADC)|(1<<PRUSI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRSPI)|(1<<PRLIN)))
01335 
01336 
01337 #elif defined(__AVR_AT90USB82__) \
01338 || defined(__AVR_AT90USB162__) \
01339 || defined(__AVR_ATmega8U2__) \
01340 || defined(__AVR_ATmega16U2__) \
01341 || defined(__AVR_ATmega32U2__)
01342 
01343 #define power_spi_enable()      (PRR0 &= (uint8_t)~(1 << PRSPI))
01344 #define power_spi_disable()     (PRR0 |= (uint8_t)(1 << PRSPI))
01345 
01346 #define power_timer0_enable()   (PRR0 &= (uint8_t)~(1 << PRTIM0))
01347 #define power_timer0_disable()  (PRR0 |= (uint8_t)(1 << PRTIM0))
01348 
01349 #define power_timer1_enable()   (PRR0 &= (uint8_t)~(1 << PRTIM1))
01350 #define power_timer1_disable()  (PRR0 |= (uint8_t)(1 << PRTIM1))
01351 
01352 #define power_usb_enable()      (PRR1 &= (uint8_t)~(1 << PRUSB))
01353 #define power_usb_disable()     (PRR1 |= (uint8_t)(1 << PRUSB))
01354 
01355 #define power_usart1_enable()   (PRR1 &= (uint8_t)~(1 << PRUSART1))
01356 #define power_usart1_disable()  (PRR1 |= (uint8_t)(1 << PRUSART1))
01357 
01358 #define power_all_enable() \
01359 do{ \
01360     PRR0 &= (uint8_t)~((1<<PRSPI)|(1<<PRTIM0)|(1<<PRTIM1)); \
01361     PRR1 &= (uint8_t)~((1<<PRUSB)|(1<<PRUSART1)); \
01362 }while(0)
01363 
01364 #define power_all_disable() \
01365 do{ \
01366     PRR0 |= (uint8_t)((1<<PRSPI)|(1<<PRTIM0)|(1<<PRTIM1)); \
01367     PRR1 |= (uint8_t)((1<<PRUSB)|(1<<PRUSART1)); \
01368 }while(0)
01369 
01370 
01371 #elif defined(__AVR_AT90SCR100__)
01372 
01373 #define power_usart0_enable()   (PRR0 &= (uint8_t)~(1 << PRUSART0))
01374 #define power_usart0_disable()  (PRR0 |= (uint8_t)(1 << PRUSART0))
01375 
01376 #define power_spi_enable()      (PRR0 &= (uint8_t)~(1 << PRSPI))
01377 #define power_spi_disable()     (PRR0 |= (uint8_t)(1 << PRSPI))
01378 
01379 #define power_timer1_enable()   (PRR0 &= (uint8_t)~(1 << PRTIM1))
01380 #define power_timer1_disable()  (PRR0 |= (uint8_t)(1 << PRTIM1))
01381 
01382 #define power_timer0_enable()   (PRR0 &= (uint8_t)~(1 << PRTIM0))
01383 #define power_timer0_disable()  (PRR0 |= (uint8_t)(1 << PRTIM0))
01384 
01385 #define power_timer2_enable()   (PRR0 &= (uint8_t)~(1 << PRTIM2))
01386 #define power_timer2_disable()  (PRR0 |= (uint8_t)(1 << PRTIM2))
01387 
01388 #define power_twi_enable()      (PRR0 &= (uint8_t)~(1 << PRTWI))
01389 #define power_twi_disable()     (PRR0 |= (uint8_t)(1 << PRTWI))
01390 
01391 #define power_usbh_enable()     (PRR1 &= (uint8_t)~(1 << PRUSBH))
01392 #define power_usbh_disable()    (PRR1 |= (uint8_t)(1 << PRUSBH))
01393 
01394 #define power_usb_enable()      (PRR1 &= (uint8_t)~(1 << PRUSB))
01395 #define power_usb_disable()     (PRR1 |= (uint8_t)(1 << PRUSB))
01396 
01397 #define power_hsspi_enable()    (PRR1 &= (uint8_t)~(1 << PRHSSPI))
01398 #define power_hsspi_disable()   (PRR1 |= (uint8_t)(1 << PRHSSPI))
01399 
01400 #define power_sci_enable()      (PRR1 &= (uint8_t)~(1 << PRSCI))
01401 #define power_sci_disable()     (PRR1 |= (uint8_t)(1 << PRSCI))
01402 
01403 #define power_aes_enable()      (PRR1 &= (uint8_t)~(1 << PRAES))
01404 #define power_aes_disable()     (PRR1 |= (uint8_t)(1 << PRAES))
01405 
01406 #define power_kb_enable()       (PRR1 &= (uint8_t)~(1 << PRKB))
01407 #define power_kb_disable()      (PRR1 |= (uint8_t)(1 << PRKB))
01408 
01409 #define power_all_enable() \
01410 do{ \
01411     PRR0 &= (uint8_t)~((1<<PRUSART0)|(1<<PRSPI)|(1<<PRTIM1)|(1<<PRTIM0)|(1<<PRTIM2)|(1<<PRTWI)); \
01412     PRR1 &= (uint8_t)~((1<<PRUSBH)|(1<<PRUSB)|(1<<PRHSSPI)|(1<<PRSCI)|(1<<PRAES)|(1<<PRKB)); \
01413 }while(0)
01414 
01415 #define power_all_disable() \
01416 do{ \
01417     PRR0 |= (uint8_t)((1<<PRUSART0)|(1<<PRSPI)|(1<<PRTIM1)|(1<<PRTIM0)|(1<<PRTIM2)|(1<<PRTWI)); \
01418     PRR1 |= (uint8_t)((1<<PRUSBH)|(1<<PRUSB)|(1<<PRHSSPI)|(1<<PRSCI)|(1<<PRAES)|(1<<PRKB)); \
01419 }while(0)
01420 
01421 
01422 #elif defined(__AVR_ATtiny4__) \
01423 || defined(__AVR_ATtiny5__) \
01424 || defined(__AVR_ATtiny9__) \
01425 || defined(__AVR_ATtiny10__) \
01426 || defined(__AVR_ATtiny13A__) \
01427 
01428 #define power_adc_enable()   (PRR &= (uint8_t)~(1 << PRADC))
01429 #define power_adc_disable()  (PRR |= (uint8_t)(1 << PRADC))
01430 
01431 #define power_timer0_enable()   (PRR &= (uint8_t)~(1 << PRTIM0))
01432 #define power_timer0_disable()  (PRR |= (uint8_t)(1 << PRTIM0))
01433 
01434 #define power_all_enable()      (PRR &= (uint8_t)~((1<<PRADC)|(1<<PRTIM0)))
01435 #define power_all_disable()     (PRR |= (uint8_t)((1<<PRADC)|(1<<PRTIM0)))
01436 
01437 
01438 #elif defined(__AVR_ATtiny20__) \
01439 || defined(__AVR_ATtiny40__)
01440 
01441 #define power_adc_enable()   (PRR &= (uint8_t)~(1 << PRADC))
01442 #define power_adc_disable()  (PRR |= (uint8_t)(1 << PRADC))
01443 
01444 #define power_timer0_enable()   (PRR &= (uint8_t)~(1 << PRTIM0))
01445 #define power_timer0_disable()  (PRR |= (uint8_t)(1 << PRTIM0))
01446 
01447 #define power_timer1_enable()   (PRR &= (uint8_t)~(1 << PRTIM1))
01448 #define power_timer1_disable()  (PRR |= (uint8_t)(1 << PRTIM1))
01449 
01450 #define power_spi_enable()   (PRR &= (uint8_t)~(1 << PRSPI))
01451 #define power_spi_disable()  (PRR |= (uint8_t)(1 << PRSPI))
01452 
01453 #define power_twi_enable()   (PRR &= (uint8_t)~(1 << PRTWI))
01454 #define power_twi_disable()  (PRR |= (uint8_t)(1 << PRTWI))
01455 
01456 #define power_all_enable()      (PRR &= (uint8_t)~((1<<PRADC)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRSPI)|(1<<PRTWI)))
01457 #define power_all_disable()     (PRR |= (uint8_t)((1<<PRADC)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRSPI)|(1<<PRTWI)))
01458 
01459 #endif
01460 
01461 
01462 #if defined(__AVR_AT90CAN32__) \
01463 || defined(__AVR_AT90CAN64__) \
01464 || defined(__AVR_AT90CAN128__) \
01465 || defined(__AVR_AT90PWM1__) \
01466 || defined(__AVR_AT90PWM2__) \
01467 || defined(__AVR_AT90PWM2B__) \
01468 || defined(__AVR_AT90PWM3__) \
01469 || defined(__AVR_AT90PWM3B__) \
01470 || defined(__AVR_AT90PWM81__) \
01471 || defined(__AVR_AT90PWM161__) \
01472 || defined(__AVR_AT90PWM216__) \
01473 || defined(__AVR_AT90PWM316__) \
01474 || defined(__AVR_AT90SCR100__) \
01475 || defined(__AVR_AT90USB646__) \
01476 || defined(__AVR_AT90USB647__) \
01477 || defined(__AVR_AT90USB82__) \
01478 || defined(__AVR_AT90USB1286__) \
01479 || defined(__AVR_AT90USB1287__) \
01480 || defined(__AVR_AT90USB162__) \
01481 || defined(__AVR_ATmega1280__) \
01482 || defined(__AVR_ATmega1281__) \
01483 || defined(__AVR_ATmega128RFA1__) \
01484 || defined(__AVR_ATmega1284P__) \
01485 || defined(__AVR_ATmega162__) \
01486 || defined(__AVR_ATmega164A__) \
01487 || defined(__AVR_ATmega164P__) \
01488 || defined(__AVR_ATmega165__) \
01489 || defined(__AVR_ATmega165A__) \
01490 || defined(__AVR_ATmega165P__) \
01491 || defined(__AVR_ATmega168__) \
01492 || defined(__AVR_ATmega168P__) \
01493 || defined(__AVR_ATmega169__) \
01494 || defined(__AVR_ATmega169A__) \
01495 || defined(__AVR_ATmega169P__) \
01496 || defined(__AVR_ATmega169PA__) \
01497 || defined(__AVR_ATmega16U4__) \
01498 || defined(__AVR_ATmega2560__) \
01499 || defined(__AVR_ATmega2561__) \
01500 || defined(__AVR_ATmega324A__) \
01501 || defined(__AVR_ATmega324P__) \
01502 || defined(__AVR_ATmega325__) \
01503 || defined(__AVR_ATmega325A__) \
01504 || defined(__AVR_ATmega325PA__) \
01505 || defined(__AVR_ATmega3250__) \
01506 || defined(__AVR_ATmega3250A__) \
01507 || defined(__AVR_ATmega3250PA__) \
01508 || defined(__AVR_ATmega328P__) \
01509 || defined(__AVR_ATmega329__) \
01510 || defined(__AVR_ATmega329A__) \
01511 || defined(__AVR_ATmega329P__) \
01512 || defined(__AVR_ATmega329PA__) \
01513 || defined(__AVR_ATmega3290__) \
01514 || defined(__AVR_ATmega3290A__) \
01515 || defined(__AVR_ATmega3290PA__) \
01516 || defined(__AVR_ATmega32C1__) \
01517 || defined(__AVR_ATmega32HVB__) \
01518 || defined(__AVR_ATmega32HVBREVB__) \
01519 || defined(__AVR_ATmega16HVB__) \
01520 || defined(__AVR_ATmega16HVBREVB__) \
01521 || defined(__AVR_ATmega32M1__) \
01522 || defined(__AVR_ATmega32U2__) \
01523 || defined(__AVR_ATmega32U4__) \
01524 || defined(__AVR_ATmega32U6__) \
01525 || defined(__AVR_ATmega48__) \
01526 || defined(__AVR_ATmega48P__) \
01527 || defined(__AVR_ATmega640__) \
01528 || defined(__AVR_ATmega649P__) \
01529 || defined(__AVR_ATmega644__) \
01530 || defined(__AVR_ATmega644A__) \
01531 || defined(__AVR_ATmega644P__) \
01532 || defined(__AVR_ATmega644PA__) \
01533 || defined(__AVR_ATmega645__) \
01534 || defined(__AVR_ATmega645A__) \
01535 || defined(__AVR_ATmega645P__) \
01536 || defined(__AVR_ATmega6450__) \
01537 || defined(__AVR_ATmega6450A__) \
01538 || defined(__AVR_ATmega6450P__) \
01539 || defined(__AVR_ATmega649__) \
01540 || defined(__AVR_ATmega649A__) \
01541 || defined(__AVR_ATmega6490__) \
01542 || defined(__AVR_ATmega6490A__) \
01543 || defined(__AVR_ATmega6490P__) \
01544 || defined(__AVR_ATmega88__) \
01545 || defined(__AVR_ATmega88P__) \
01546 || defined(__AVR_ATtiny48__) \
01547 || defined(__AVR_ATtiny167__) \
01548 || defined(__DOXYGEN__)
01549 
01550 
01551 /** \addtogroup avr_power
01552 
01553 Some of the newer AVRs contain a System Clock Prescale Register (CLKPR) that
01554 allows you to decrease the system clock frequency and the power consumption
01555 when the need for processing power is low. Below are two macros and an
01556 enumerated type that can be used to interface to the Clock Prescale Register.
01557 
01558 \note Not all AVR devices have a Clock Prescale Register. On those devices
01559 without a Clock Prescale Register, these macros are not available.
01560 */
01561 
01562 
01563 /** \addtogroup avr_power
01564 \code 
01565 typedef enum
01566 {
01567     clock_div_1 = 0,
01568     clock_div_2 = 1,
01569     clock_div_4 = 2,
01570     clock_div_8 = 3,
01571     clock_div_16 = 4,
01572     clock_div_32 = 5,
01573     clock_div_64 = 6,
01574     clock_div_128 = 7,
01575     clock_div_256 = 8,
01576     clock_div_1_rc = 15, // ATmega128RFA1 only
01577 } clock_div_t;
01578 \endcode
01579 Clock prescaler setting enumerations.
01580 
01581 */
01582 typedef enum
01583 {
01584     clock_div_1 = 0,
01585     clock_div_2 = 1,
01586     clock_div_4 = 2,
01587     clock_div_8 = 3,
01588     clock_div_16 = 4,
01589     clock_div_32 = 5,
01590     clock_div_64 = 6,
01591     clock_div_128 = 7,
01592     clock_div_256 = 8
01593 #if defined(__AVR_ATmega128RFA1__)
01594     , clock_div_1_rc = 15
01595 #endif
01596 } clock_div_t;
01597 
01598 
01599 static __inline__ void clock_prescale_set(clock_div_t) __attribute__((__always_inline__));
01600 
01601 /** \addtogroup avr_power
01602 \code clock_prescale_set(x) \endcode
01603 
01604 Set the clock prescaler register select bits, selecting a system clock
01605 division setting. This function is inlined, even if compiler
01606 optimizations are disabled.
01607 
01608 The type of x is clock_div_t.
01609 */
01610 void clock_prescale_set(clock_div_t __x)
01611 {
01612     uint8_t __tmp = _BV(CLKPCE);
01613     __asm__ __volatile__ (
01614         "in __tmp_reg__,__SREG__" "\n\t"
01615         "cli" "\n\t"
01616         "sts %1, %0" "\n\t"
01617         "sts %1, %2" "\n\t"
01618         "out __SREG__, __tmp_reg__"
01619         : /* no outputs */
01620         : "d" (__tmp),
01621           "M" (_SFR_MEM_ADDR(CLKPR)),
01622           "d" (__x)
01623         : "r0");
01624 }
01625 
01626 /** \addtogroup avr_power
01627 \code clock_prescale_get() \endcode
01628 Gets and returns the clock prescaler register setting. The return type is clock_div_t.
01629 
01630 */
01631 #define clock_prescale_get()  (clock_div_t)(CLKPR & (uint8_t)((1<<CLKPS0)|(1<<CLKPS1)|(1<<CLKPS2)|(1<<CLKPS3)))
01632 
01633 
01634 #elif defined(__AVR_ATtiny24__) \
01635 || defined(__AVR_ATtiny24A__) \
01636 || defined(__AVR_ATtiny44__) \
01637 || defined(__AVR_ATtiny44A__) \
01638 || defined(__AVR_ATtiny84__) \
01639 || defined(__AVR_ATtiny84A__) \
01640 || defined(__AVR_ATtiny25__) \
01641 || defined(__AVR_ATtiny45__) \
01642 || defined(__AVR_ATtiny85__) \
01643 || defined(__AVR_ATtiny261A__) \
01644 || defined(__AVR_ATtiny261__) \
01645 || defined(__AVR_ATtiny461__) \
01646 || defined(__AVR_ATtiny461A__) \
01647 || defined(__AVR_ATtiny861__) \
01648 || defined(__AVR_ATtiny861A__) \
01649 || defined(__AVR_ATtiny2313__) \
01650 || defined(__AVR_ATtiny2313A__) \
01651 || defined(__AVR_ATtiny4313__) \
01652 || defined(__AVR_ATtiny13__) \
01653 || defined(__AVR_ATtiny13A__) \
01654 || defined(__AVR_ATtiny43U__) \
01655 
01656 typedef enum
01657 {
01658     clock_div_1 = 0,
01659     clock_div_2 = 1,
01660     clock_div_4 = 2,
01661     clock_div_8 = 3,
01662     clock_div_16 = 4,
01663     clock_div_32 = 5,
01664     clock_div_64 = 6,
01665     clock_div_128 = 7,
01666     clock_div_256 = 8
01667 } clock_div_t;
01668 
01669 static __inline__ void clock_prescale_set(clock_div_t) __attribute__((__always_inline__));
01670 
01671 void clock_prescale_set(clock_div_t __x)
01672 {
01673     uint8_t __tmp = _BV(CLKPCE);
01674     __asm__ __volatile__ (
01675         "in __tmp_reg__,__SREG__" "\n\t"
01676         "cli" "\n\t"
01677         "out %1, %0" "\n\t"
01678         "out %1, %2" "\n\t"
01679         "out __SREG__, __tmp_reg__"
01680         : /* no outputs */
01681         : "d" (__tmp),
01682           "I" (_SFR_IO_ADDR(CLKPR)),
01683           "d" (__x)
01684         : "r0");
01685 }
01686 
01687 
01688 #define clock_prescale_get()  (clock_div_t)(CLKPR & (uint8_t)((1<<CLKPS0)|(1<<CLKPS1)|(1<<CLKPS2)|(1<<CLKPS3)))
01689 
01690 
01691 #endif
01692 
01693 
01694 
01695 
01696 #endif /* _AVR_POWER_H_ */

Automatically generated by Doxygen 1.7.1 on Mon Feb 21 2011.